使用Azure资源管理器模板配置CORS [英] Configure CORS by using Azure Resource Manager template
问题描述
我正在尝试使用Azure资源管理器工具在配置CORS"下为我的存储帐户设置CORS规则: https://docs.microsoft.com/zh-cn/azure/app-service-api/app-service- api-cors-consume-javascript
I'm trying to set CORS rule for my storage account as suggested here under Configure CORS by using Azure Resource Manager tools: https://docs.microsoft.com/en-us/azure/app-service-api/app-service-api-cors-consume-javascript
通过添加属性cors:
by adding property cors:
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"sku": {
"name": "Standard_RAGRS",
"tier": "Standard"
},
"kind": "Storage",
"name": "[parameters('storageAccounts_teststoragejkjk_name')]",
"apiVersion": "2016-01-01",
"location": "westus",
"tags": {},
"properties": {
"cors": {"allowedOrigins": ["*"]}
},
"resources": [],
"dependsOn": []
}
]
部署成功,我可以在Azure门户的活动日志"下看到写入StorageAccount"操作,但是Cors规则未添加到任何地方,当我从Azure下载模板时,它没有此"cors属性".
Deployment returns succes and I can see Write StorageAccount operation under Activity Log in Azure Portal but Cors Rules aren't added anywhere and when i download template from Azure it doesn't have this "cors property".
我还尝试过手动添加Corse Rule(我只需要在我的Blob上添加它),自动化脚本(包括deployment.ps)看起来还是一样...
I also tried manually adding Corse Rule (i need it only on my Blob) and automation scripts (including deployment.ps) still looks the same...
关于如何使用ARM模板在blob存储上配置Cors规则的任何建议?
Any suggestion on how to configure Cors rule on blob storage using ARM templates?
推荐答案
您的部署客户端是什么? 如果您正在使用Powershell部署ARM(可能是这样),为什么不使用
What is your deployment client? If you are using Powershell to deploy ARM (w you probably are) why not use Set-AzureStorageCORSRule?
PS C:\>$CorsRules = (@{
AllowedHeaders=@("x-ms-blob-content-type","x-ms-blob-content-disposition");
AllowedOrigins=@("*");
MaxAgeInSeconds=30;
AllowedMethods=@("Get","Connect")},
@{
AllowedOrigins=@("http://www.fabrikam.com","http://www.contoso.com");
ExposedHeaders=@("x-ms-meta-data*","x-ms-meta-customheader");
AllowedHeaders=@("x-ms-meta-target*","x-ms-meta-customheader");
MaxAgeInSeconds=30;
AllowedMethods=@("Put")})
PS C:\> Set-AzureStorageCORSRule -ServiceType Blob -CorsRules $CorsRules
这篇关于使用Azure资源管理器模板配置CORS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!