gpt4 book ai didi

azure - 使用 Azure 资源管理器模板配置 CORS

转载 作者:行者123 更新时间:2023-12-02 22:04:14 25 4
gpt4 key购买 nike

我正在尝试按照使用 Azure 资源管理器工具配置 CORS 下的建议为我的存储帐户设置 CORS 规则:https://learn.microsoft.com/en-us/azure/app-service-api/app-service-api-cors-consume-javascript

通过添加属性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 门户中的事件日志下看到 Write StorageAccount 操作,但 Cors 规则未添加到任何地方,并且当我从 Azure 下载模板时,它没有此“cors 属性”。

我还尝试手动添加 Corse 规则(我只在我的 Blob 上需要它)并且自动化脚本(包括部署.ps)看起来仍然相同...

关于如何使用 ARM 模板在 Blob 存储上配置 Cors 规则有什么建议吗?

最佳答案

正如 @JBA 指出的那样,现在可以通过 ARM templates 来实现.

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "storageAccountName",
"apiVersion": "2018-02-01",
"location": "northeurope",
"kind": "StorageV2",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"tags": {},
"dependsOn": [],
"properties": {
"accessTier": "Hot"
},
"resources": [
{
"name": "default",
"type": "blobServices",
"apiVersion": "2018-11-01",
"dependsOn": [
"storageAccountName"
],
"properties": {
"cors": {
"corsRules": [
{
"allowedOrigins": [
"https://mywebsite.com"
],
"allowedMethods": [
"GET"
],
"maxAgeInSeconds": 0,
"exposedHeaders": [
"*"
],
"allowedHeaders": [
"*"
]
}
]
}
},
"resources": []
},
{
"type": "blobServices/containers",
"apiVersion": "2018-03-01-preview",
"name": "[concat('default/', 'myFilesToShare')]",
"dependsOn": [
"storageAccountName"
],
"properties": {
"publicAccess": "Blob"
}
}
]
}
]
}

关于azure - 使用 Azure 资源管理器模板配置 CORS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41173859/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com