如何使用脚本在 blob 服务上启用/禁用静态网站

问题描述

为了以编程方式自动启用 Blob 服务上的静态网站。属性字段应该是什么?我找不到与此 Microsoft.Storage/storageAccounts/blobService/staticWebsite 类似的内容

谁能帮我解决这个问题?

解决方法

确实,您可以使用一些 Azure CLI 命令来实现。

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

要设置切换 staticWebsite.enabled 属性,您可以使用 az storage blob service-properties update 命令,如下所示:

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

上述的 Azure PowerShell 等效项是 Enable-AzStorageStaticWebsiteDisable-AzStorageStaticWebsite cmdlets