gpt4 book ai didi

azure - 通过 ARM 模板创建 Azure blob/文件共享容器

转载 作者:行者123 更新时间:2023-12-03 23:33:26 25 4
gpt4 key购买 nike

我正在寻找一种通过 ARM 模板在 Azure blob 和文件共享存储中创建容器的方法。

目前我有 ARM 模板来配置存储帐户,但我想也在 ARM 中创建容器。

{
"name": "[parameters('storageAccountName')]",
"type": "Microsoft.Storage/storageAccounts",
"location": "[resourceGroup().location]",
"apiVersion": "[variables('storageApiVersion')]",
"sku": {
"name": "[variables('storageAccountType')]"
},
"dependsOn": [ ],
"tags": {
"Environment": "[parameters('Environment')]",
"Project": "[parameters('ProjectName')]",
"Contact": "[parameters('ContactName')]"
},
"kind": "Storage",
"properties": {
"encryption": {
"keySource": "Microsoft.Storage",
"services": {
"blob": {
"enabled": true
}
}
}
}
}

最佳答案

这是可能的。 Azure 管理 REST Api 现在具有 Blob 容器的端点:https://learn.microsoft.com/en-us/rest/api/storagerp/blobcontainers/create .

由于 ARM 模板映射到 REST 请求,我们可以创建以下模板,其中包含 Blob 容器作为存储帐户下方的嵌套资源。当然,您也可以按照通常的规则在顶级资源数组中描述Blob容器。

{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {
"accountName": "accountname",
"containerName": "containername"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('accountName')]",
"apiVersion": "2018-02-01",
"location": "westeurope",
"kind": "BlobStorage",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"tags": {},
"dependsOn": [],
"properties": {
"accessTier": "Cool"
},
"resources": [
{
"type": "blobServices/containers",
"apiVersion": "2018-03-01-preview",
"name": "[concat('default/', variables('containerName'))]",
"dependsOn": [
"[variables('accountName')]"
],
"properties": {
"publicAccess": "None"
}
}
]
}
]
}

关于azure - 通过 ARM 模板创建 Azure blob/文件共享容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41004779/

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