【问题标题】:How to move subscription under management group using ARM templates?如何使用 ARM 模板在管理组下移动订阅?
【发布时间】:2020-12-13 15:08:21
【问题描述】:

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

我尝试以两种方式定义订阅子资源,但两种部署都失败并出现相同的错误:'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": {}
}

【问题讨论】:

    标签: azure-resource-manager arm-template azure-management-groups


    【解决方案1】:

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

    {
      "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')]"
          ]
        }
      ]
    }
    

    【讨论】:

      猜你喜欢
      • 2019-11-05
      • 2020-12-27
      • 2015-06-24
      • 2020-12-08
      • 2017-03-28
      • 2021-03-25
      • 1970-01-01
      • 1970-01-01
      • 2018-03-14
      相关资源
      最近更新 更多