0

如何通过 ARM 模板在管理组下移动订阅?这应该可以通过以下资源提供程序实现:Microsoft.Management managementGroups/subscriptions 模板参考

我尝试以两种方式定义订阅子资源,但两种部署都失败并出现相同的错误:'error': {'code': 'InternalServerError', 'message': "(...) 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed. (...)" } }.

选项1:

{
    "$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "managementGroupName": {
            "type": "String",
            "metadata": {
                "description": "The management group to be configured"
            }
        },
        "childSubscription": {
            "type": "String",
            "metadata": {
                "description": "The list of child subscription IDs of the management group"
            }
        }
    },
    "variables": {},
    "functions": [],
    "resources": [
        {
            "type": "Microsoft.Management/managementGroups",
            "apiVersion": "2019-11-01",
            "name": "[parameters('managementGroupName')]",
            "resources": [
                {
                    "type": "subscriptions",
                    "apiVersion": "2020-05-01",
                    "name": "[parameters('childSubscription')]",
                    "dependsOn": [
                        "[parameters('managementGroupName')]"
                    ]
                }
            ]
        }
    ],
    "outputs": {}
}

选项 2:

{
    "$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "managementGroupName": {
            "type": "String",
            "metadata": {
                "description": "The management group to be configured"
            }
        },
        "childSubscription": {
            "type": "String",
            "metadata": {
                "description": "The list of child subscription IDs of the management group"
            }
        }
    },
    "variables": {},
    "functions": [],
    "resources": [
        {
            "type": "Microsoft.Management/managementGroups/subscriptions",
            "apiVersion": "2020-05-01",
            "name": "[concat(parameters('managementGroupName'), '/', parameters('childSubscription'))]"
        }
    ],
    "outputs": {}
}
4

1 回答 1

1

部署必须在租户级别而不是管理组级别完成。然后资源定义变为:

{
  "type": "Microsoft.Management/managementGroups",
  "apiVersion": "2019-11-01",
  "name": "[variables('managementGroupName')]",
  "properties": {},
  "resources": [
    {
      "type": "subscriptions",
      "apiVersion": "2020-05-01",
      "name": "[parameters('childSubscriptionId')]",
      "dependsOn": [
        "[variables('managementGroupName')]"
      ]
    }
  ]
}
于 2020-08-24T23:50:25.767 回答