如何通过脚本设置Azure Storage的defaultToOAuthAuthentication属性
通过Azure CLI设置存储账户的defaultToOAuthAuthentication属性
可以通过Azure CLI脚本完成该属性的设置,支持创建存储账户时配置和修改已有存储账户两种场景,具体命令如下:
1. 创建存储账户时启用该属性
使用az storage account create命令,添加--default-to-oauth-authentication true参数即可在创建时直接开启默认OAuth认证:
az storage account create \ --name <你的存储账户名称> \ --resource-group <你的资源组名称> \ --location <区域名称> \ --sku Standard_LRS \ --default-to-oauth-authentication true
2. 修改已存在的存储账户
如果存储账户已创建,使用az storage account update命令更新该属性:
az storage account update \ --name <你的存储账户名称> \ --resource-group <你的资源组名称> \ --default-to-oauth-authentication true
注意事项
- 确保你的Azure CLI是最新版本,若版本过旧可能不支持该参数,可执行
az upgrade命令更新CLI。 - 设置该属性后,后续新建的存储容器会默认使用Azure AD授权进行数据操作,和Azure门户设置的效果一致。
内容的提问来源于stack exchange,提问作者orange-lily
相关产品推荐
相关产品推荐

