【发布时间】:2018-07-18 01:42:50
【问题描述】:
我正在尝试根据这篇文章在 ARM 模板中设置一些标签:https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-templates-resources#apply-an-object-to-the-tag-element
我希望能够在 TagValues 参数中设置几个通用标签,然后为特定资源附加其他标签。这可能吗,如果可以,怎么办?我尝试过使用 [concat()] 但它对处理对象不满意,并且验证失败。
这是我正在尝试做的一个示例:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"tagValues": {
"type": "object",
"defaultValue": {
"Dept": "Finance",
"Environment": "Production"
}
}
},
"resources": [
{
"apiVersion": "2016-01-01",
"type": "Microsoft.Storage/storageAccounts",
"name": "[concat('storage', uniqueString(resourceGroup().id))]",
"location": "[resourceGroup().location]",
"tags": "[parameters('tagValues')]", // want to concatenate another tag here, so that the following is returned: "Dept": "Finance", "Environment": "Production", "myExtraTag": "myTagValue"
"sku": {
"name": "Standard_LRS"
},
"kind": "Storage",
"properties": {}
}
{
"apiVersion": "2016-01-01",
"type": "Microsoft.Storage/storageAccounts",
"name": "mySecondResource",
"location": "[resourceGroup().location]",
"tags": "[parameters('tagValues')]", // want to concatenate a DIFFERENT tag here, so that the following is returned: "Dept": "Finance", "Environment": "Production", "myExtraDifferentTag": "myDifferentTagValue"
"sku": {
"name": "Standard_LRS"
},
"kind": "Storage",
"properties": {}
}
]
}
【问题讨论】:
-
嘿,格雷格,我相信这是可能的,你能分享一些你在问题中使用的 json 吗?
-
@LachieWhite 添加了带有注释的代码示例,解释了我正在尝试做什么。
标签: azure azure-resource-manager arm-template