【发布时间】:2019-09-17 21:32:45
【问题描述】:
我想部署一个嵌套的 azure arm 模板,我需要提示如何重用主模板中定义的变量。
在 azuredeploy.json 中,我声明了一些要在模板中使用的变量。
"variables": {
"nestedtemplateUriStorage": "[uri(parameters('_artifactsLocation'), concat('nestedtemplates/storage.json', parameters('_artifactsLocationSasToken')))]",
"location": "[resourceGroup().location]",
"DiagStorageName": "[tolower(concat(parameters('Kundenkuerzel'),'sadiag'))]",
"DiagStorageType": "Standard_LRS"
},
"resources": [
{
"name": "storage",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2018-05-01",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('nestedtemplateUriStorage')]"
},
"variables": {
"location":{"value": "[variables('location')]" },
"DiagStorageName" :{"value": "[variables('DiagStorageName')]" },
"DiagStorageType" :{"value": "[variables('DiagStorageType')]" }
}
}
},
我的 storage.json 如下所示。
{
...
},
"variables": {
"location": "[variables('location')]",
"DiagStorageName": "[variables('DiagStorageName')]",
"DiagStorageType": "[variables('DiagStorageType')]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('DiagStorageName')]",
"apiVersion": "2015-06-15",
"location": "[variables('location')]",
"tags": {
"displayName": "StorageAccount"
},
"properties": {
"accountType": "[variables('DiagStorageType')]"
}
}
]
}
如何在链接模板中使用主模板中声明的变量?
【问题讨论】:
标签: azure templates azure-resource-manager