Как переместить подписку в группе управления с использованием шаблонов ARM?

#azure-resource-manager #arm-template #azure-management-groups

#azure-resource-manager #azure-rm-template #azure-management-groups

Вопрос:

Как я могу переместить подписку в группу управления с помощью шаблона 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": {}
}
  

Ответ №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')]"
      ]
    }
  ]
}