0

我正在尝试使用 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 文档的一部分时它会失败!任何的想法?

4

1 回答 1

0

管理组中不需要位置。您可以查看此 Azure 创建管理组 REST API文档,此处不需要位置。

这就是为什么在模板中您可以删除该位置,或者您可以提供“全局”作为值,正如测试命令输出所指定的那样。

于 2022-03-04T05:48:00.230 回答