通过 ARM 模板在存储帐户中部署多个容器
Deploy multiple containers in the storage account via ARM Template
是否可以通过 ARM 模板在存储帐户中部署多个 (2) 容器?
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "",
"apiVersion": "",
"location": "",
"kind": "",
"sku": {
"name": ""
},
"resources": [
{
"name": "[concat('default/', parameters('containerName'))]",
"type": "blobServices/containers"
}
]
}
]
是的,你可以。
例如,您可以使用下面的模板创建一个存储帐户,其中包含两个名为 container1
和 container2
的容器。
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccounts_joy12_name": {
"type": "String"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "[parameters('storageAccounts_joy12_name')]",
"location": "eastus",
"sku": {
"name": "Standard_RAGRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
"networkAcls": {
"bypass": "AzureServices",
"virtualNetworkRules": [],
"ipRules": [],
"defaultAction": "Allow"
},
"supportsHttpsTrafficOnly": true,
"encryption": {
"services": {
"file": {
"keyType": "Account",
"enabled": true
},
"blob": {
"keyType": "Account",
"enabled": true
}
},
"keySource": "Microsoft.Storage"
},
"accessTier": "Hot"
}
},
{
"type": "Microsoft.Storage/storageAccounts/blobServices",
"apiVersion": "2019-06-01",
"name": "[concat(parameters('storageAccounts_joy12_name'), '/default')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_joy12_name'))]"
],
"sku": {
"name": "Standard_RAGRS",
"tier": "Standard"
},
"properties": {
"cors": {
"corsRules": []
},
"deleteRetentionPolicy": {
"enabled": false
}
}
},
{
"type": "Microsoft.Storage/storageAccounts/fileServices",
"apiVersion": "2019-06-01",
"name": "[concat(parameters('storageAccounts_joy12_name'), '/default')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_joy12_name'))]"
],
"sku": {
"name": "Standard_RAGRS",
"tier": "Standard"
},
"properties": {
"cors": {
"corsRules": []
}
}
},
{
"type": "Microsoft.Storage/storageAccounts/blobServices/containers",
"apiVersion": "2019-06-01",
"name": "[concat(parameters('storageAccounts_joy12_name'), '/default/container1')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccounts_joy12_name'), 'default')]",
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_joy12_name'))]"
],
"properties": {
"publicAccess": "None"
}
},
{
"type": "Microsoft.Storage/storageAccounts/blobServices/containers",
"apiVersion": "2019-06-01",
"name": "[concat(parameters('storageAccounts_joy12_name'), '/default/container2')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccounts_joy12_name'), 'default')]",
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_joy12_name'))]"
],
"properties": {
"publicAccess": "None"
}
}
]
}
您可能想将这种简单的方法换成更易于管理的方法:
"variables": [
"blobs": [
"myfirstblob",
"myotherblob"
]
],
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "",
"apiVersion": "",
"location": "",
"kind": "",
"sku": {
"name": ""
},
"resources": [
{
"name": "[concat('default/', variables('blobs')[copyIndex()])]",
"type": "blobServices/containers",
"apiVersion": "",
"copy": {
"name": "blobIterator",
"count": "[length(variables('blobs'))]"
}
}
]
}
]
是否可以通过 ARM 模板在存储帐户中部署多个 (2) 容器?
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "",
"apiVersion": "",
"location": "",
"kind": "",
"sku": {
"name": ""
},
"resources": [
{
"name": "[concat('default/', parameters('containerName'))]",
"type": "blobServices/containers"
}
]
}
]
是的,你可以。
例如,您可以使用下面的模板创建一个存储帐户,其中包含两个名为 container1
和 container2
的容器。
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccounts_joy12_name": {
"type": "String"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "[parameters('storageAccounts_joy12_name')]",
"location": "eastus",
"sku": {
"name": "Standard_RAGRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
"networkAcls": {
"bypass": "AzureServices",
"virtualNetworkRules": [],
"ipRules": [],
"defaultAction": "Allow"
},
"supportsHttpsTrafficOnly": true,
"encryption": {
"services": {
"file": {
"keyType": "Account",
"enabled": true
},
"blob": {
"keyType": "Account",
"enabled": true
}
},
"keySource": "Microsoft.Storage"
},
"accessTier": "Hot"
}
},
{
"type": "Microsoft.Storage/storageAccounts/blobServices",
"apiVersion": "2019-06-01",
"name": "[concat(parameters('storageAccounts_joy12_name'), '/default')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_joy12_name'))]"
],
"sku": {
"name": "Standard_RAGRS",
"tier": "Standard"
},
"properties": {
"cors": {
"corsRules": []
},
"deleteRetentionPolicy": {
"enabled": false
}
}
},
{
"type": "Microsoft.Storage/storageAccounts/fileServices",
"apiVersion": "2019-06-01",
"name": "[concat(parameters('storageAccounts_joy12_name'), '/default')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_joy12_name'))]"
],
"sku": {
"name": "Standard_RAGRS",
"tier": "Standard"
},
"properties": {
"cors": {
"corsRules": []
}
}
},
{
"type": "Microsoft.Storage/storageAccounts/blobServices/containers",
"apiVersion": "2019-06-01",
"name": "[concat(parameters('storageAccounts_joy12_name'), '/default/container1')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccounts_joy12_name'), 'default')]",
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_joy12_name'))]"
],
"properties": {
"publicAccess": "None"
}
},
{
"type": "Microsoft.Storage/storageAccounts/blobServices/containers",
"apiVersion": "2019-06-01",
"name": "[concat(parameters('storageAccounts_joy12_name'), '/default/container2')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccounts_joy12_name'), 'default')]",
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_joy12_name'))]"
],
"properties": {
"publicAccess": "None"
}
}
]
}
您可能想将这种简单的方法换成更易于管理的方法:
"variables": [
"blobs": [
"myfirstblob",
"myotherblob"
]
],
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "",
"apiVersion": "",
"location": "",
"kind": "",
"sku": {
"name": ""
},
"resources": [
{
"name": "[concat('default/', variables('blobs')[copyIndex()])]",
"type": "blobServices/containers",
"apiVersion": "",
"copy": {
"name": "blobIterator",
"count": "[length(variables('blobs'))]"
}
}
]
}
]