Search code examples
azureazure-storageazure-blob-storage

How to enable/disable staticwebsite on blob service using script


In order to programmatically automate enablement of the static website on blob service. What should be the property field allowed? I am unable to find something similar to this Microsoft.Storage/storageAccounts/blobService/staticWebsite.

Can anyone help me with this?


Solution

  • Indeed, you can do so with some Azure CLI commands.

    # To query the current status of the property
    az storage blob service-properties show --account-name <your-storage-account> --query 'staticWebsite.enabled'
    

    To set toggle the staticWebsite.enabled property, you can use the az storage blob service-properties update command as follows:

    az storage blob service-properties update --account-name <your-storage-account> --static-website
    

    The Azure PowerShell equivalents for the above would be the Enable-AzStorageStaticWebsite and Disable-AzStorageStaticWebsite cmdlets.