【发布时间】:2021-10-26 17:00:03
【问题描述】:
我通过使用以下 ARM 模板添加现有虚拟网络创建了 Azure 存储帐户。
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountName": {
"type": "string",
"metadata": {
"description": "Specifies the name of the Azure Storage account."
}
},
"storageAccountType": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_GRS",
"Standard_RAGRS",
"Standard_ZRS",
"Premium_LRS"
],
"metadata": {
"description": "Storage Account type."
}
},
"storageAccessTier": {
"type": "string",
"defaultValue": "Hot",
"allowedValues": [
"Hot",
"Cool"
],
"metadata": {
"description": "Set the access tier of the Storage Account."
}
},
"storageKind": {
"type": "string",
"defaultValue": "StorageV2",
"allowedValues": [
"StorageV2",
"Storage"
],
"metadata": {
"description": "Set the storage kind of the Storage Account."
}
},
"storageAccounthttpsTrafficOnlyEnabled": {
"type": "bool",
"defaultValue": true,
"metadata": {
"description": "Enable or disable enforcing HTTPS only access."
}
},
"allowBlobPublicAccess": {
"type": "bool",
"defaultValue": false,
"metadata": {
"description": "Enable or disable blob public access"
}
},
"isHnsEnabled": {
"type": "bool",
"defaultValue": true,
"metadata": {
"description": "Enable or disable ADLS Gen2 hierarchical namespace"
}
},
"containerNames": {
"type": "array",
"metadata": {
"description": "The container names"
}
},
"location": {
"type": "string",
"metadata": {
"description": "Specifies the location in which the Azure Storage resources should be deployed."
}
},
"environment": {
"type": "string",
"metadata": {
"description": "Specify the environment name"
}
},
"subscriptionOwner": {
"type": "string",
"metadata": {
"description": "Specify the email address of the subscription owner"
}
},
"vnetResourceGroupName": {
"type": "string",
"metadata": {
"description": "The name of the existing resource group which contains the virtual network"
}
},
"vnetName": {
"type": "string",
"metadata": {
"description": "The name of the existing virtual network"
}
},
"subnet01Name": {
"type": "string",
"metadata": {
"description": "The name of the db subnet"
}
},
"subnet02Name": {
"type": "string",
"metadata": {
"description": "The name of the default subnet"
}
},
"subnet03Name": {
"type": "string",
"metadata": {
"description": "The name of the ise1 subnet"
}
},
"subnet04Name": {
"type": "string",
"metadata": {
"description": "The name of the ise2 subnet"
}
},
"subnet05Name": {
"type": "string",
"metadata": {
"description": "The name of the ise3 subnet"
}
},
"subnet06Name": {
"type": "string",
"metadata": {
"description": "The name of the ise4 subnet"
}
},
"subnet07Name": {
"type": "string",
"metadata": {
"description": "The name of the tools subnet"
}
}
},
"variables": {
"vnetResourceId": "[resourceId(parameters('vnetResourceGroupName'),'Microsoft.Network/virtualNetworks',parameters('vnetName'))]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2020-08-01-preview",
"name": "[parameters('storageAccountName')]",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('storageAccountType')]",
"tier": "Standard"
},
"kind": "[parameters('storageKind')]",
"properties": {
"accessTier": "[parameters('storageAccessTier')]",
"allowBlobPublicAccess": "[parameters('allowBlobPublicAccess')]",
"isHnsEnabled": "[parameters('isHnsEnabled')]",
"supportsHttpsTrafficOnly": "[parameters('storageAccounthttpsTrafficOnlyEnabled')]",
"networkAcls": {
"resourceAccessRules": [
],
"bypass": "AzureServices",
"virtualNetworkRules": [
{
"id": "[concat(variables('vnetResourceId'), '/subnets/',parameters('subnet01Name'))]",
"action": "Allow",
"state": "Succeeded"
},
{
"id": "[concat(variables('vnetResourceId'), '/subnets/',parameters('subnet02Name'))]",
"action": "Allow",
"state": "Succeeded"
},
{
"id": "[concat(variables('vnetResourceId'), '/subnets/',parameters('subnet03Name'))]",
"action": "Allow",
"state": "Succeeded"
},
{
"id": "[concat(variables('vnetResourceId'), '/subnets/',parameters('subnet04Name'))]",
"action": "Allow",
"state": "Succeeded"
},
{
"id": "[concat(variables('vnetResourceId'), '/subnets/',parameters('subnet05Name'))]",
"action": "Allow",
"state": "Succeeded"
},
{
"id": "[concat(variables('vnetResourceId'), '/subnets/',parameters('subnet06Name'))]",
"action": "Allow",
"state": "Succeeded"
},
{
"id": "[concat(variables('vnetResourceId'), '/subnets/',parameters('subnet07Name'))]",
"action": "Allow",
"state": "Succeeded"
}
],
"ipRules": [
{
"value": "xxxxxxxx",
"action": "Allow"
}
],
"defaultAction": "Deny"
}
}
},
{
"type": "Microsoft.Storage/storageAccounts/blobServices/containers",
"apiVersion": "2020-08-01-preview",
"name": "[concat(parameters('storageAccountName'),'/default/', parameters('containerNames')[copyIndex()])]",
"copy": {
"name": "containercopy",
"count": "[length(parameters('containerNames'))]"
},
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
]
}
],
"outputs": {
"storageAccountName": {
"type": "string",
"value": "[parameters('storageAccountName')]"
},
"containerNames": {
"type": "array",
"value": "[parameters('containerNames')]"
}
}
}
在上面的模板中,我使用了多个参数来提供虚拟网络和子网。但我想使用复制操作符来添加现有的虚拟网络和子网。
【问题讨论】:
标签: azure azure-storage arm-template azure-virtual-network subnet