我正在尝试使用 Azure 管理组 Arm 模板。
正如您在此链接中看到的,我有这个 Arm 模板:
{
"$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"mgName": {
"type": "string",
"defaultValue": "[concat('mg-', uniqueString(newGuid()))]"
}
},
"resources": [
{
"type": "Microsoft.Management/managementGroups",
"apiVersion": "2021-04-01",
"name": "[parameters('mgName')]",
"scope": "/",
"location": "eastus",
"properties": {}
}
],
"outputs": {
"output": {
"type": "string",
"value": "[parameters('mgName')]"
}
}
}
另存为mg.json
,它工作正常。
后来我开始尝试使用Test-AzTemplate
( https://github.com/Azure/arm-ttk ) 验证和测试 Arm 模板。当我运行以下命令来测试 Arm 模板时:
Test-AzTemplate -TemplatePath .\mg.json
我得到这个测试错误:
[-] Resources Should Have Location (3 ms)
Resource [parameters('mgName')] Location must be an expression or 'global'
现在,当我删除"location": "eastus",
线形 Arm 模板时,测试不会失败并通过测试。
我的问题:
管理组臂中的这个位置是必需的还是不需要的?以及为什么当它是 Microsoft 文档的一部分时它会失败!任何的想法?