如何使用 ARM 模板在管理组下移动订阅?
How to move subscription under management group using ARM templates?
如何通过 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": {}
}
部署必须在 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')]"
]
}
]
}
如何通过 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": {}
}
部署必须在 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')]"
]
}
]
}