ARM 템플릿을 사용하여 관리 그룹 배포

조직이 성장하면 ARM 템플릿(Azure Resource Manager 템플릿)을 배포하여 관리 그룹 수준에서 리소스를 만들 수 있습니다. 예를 들어 관리 그룹에 대한 정책을 정의하고 할당하거나 Azure RBAC(역할 기반 액세스 제어)를 할당해야 할 수 있습니다. 관리 그룹 수준 템플릿을 사용하면 선언적으로 정책을 적용하고 관리 그룹 수준에서 역할을 할당할 수 있습니다.

ARM 템플릿과 동일한 기능을 제공하고 구문이 사용하기 더 쉽기 때문에 Bicep를 권장합니다. 자세한 내용은 관리 그룹 배포를 참조하세요.

지원되는 리소스

모든 리소스 종류를 관리 그룹 수준에 배포할 수 있는 것은 아닙니다. 이 섹션에서는 지원되는 리소스 종류를 나열합니다.

Azure Blueprints의 경우 다음을 사용합니다.

Azure Policy의 경우 다음을 사용합니다.

액세스 제어를 위해 다음을 사용합니다.

구독 또는 리소스 그룹에 배포하는 중첩된 템플릿의 경우 다음을 사용합니다.

리소스를 관리하려면 다음을 사용합니다.

관리 그룹은 테넌트 수준 리소스입니다. 그러나 새 관리 그룹의 범위를 테넌트로 설정하여 관리 그룹 배포에서 관리 그룹을 만들 수 있습니다. 관리 그룹을 참조하세요.

스키마

관리 그룹 배포에 사용하는 스키마는 리소스 그룹 배포에 대한 스키마와 다릅니다.

템플릿의 경우 다음을 사용합니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#",
  ...
}

매개 변수 파일에 대한 스키마는 모든 배포 범위에 대해 동일합니다. 매개 변수 파일의 경우 다음을 사용합니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
  ...
}

배포 명령

관리 그룹에 배포하려면 관리 그룹 배포 명령을 사용합니다.

Azure CLI의 경우 az deployment mg create를 사용합니다.

az deployment mg create \
  --name demoMGDeployment \
  --location WestUS \
  --management-group-id myMG \
  --template-uri "https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/management-level-deployment/azuredeploy.json"

ARM 템플릿 배포를 위한 배포 명령 및 옵션에 대한 자세한 내용은 다음을 참조하세요.

배포 위치 및 이름

관리 그룹 수준 배포의 경우 배포할 위치를 제공해야 합니다. 배포 위치는 배포하는 리소스의 위치와는 별개입니다. 배포 위치는 배포 데이터를 저장할 위치를 지정합니다. 구독테넌트 배포에도 위치가 필요합니다. 리소스 그룹 배포의 경우 배포 데이터를 저장하는 데 리소스 그룹의 위치가 사용됩니다.

배포 이름을 제공하거나 기본 배포 이름을 사용할 수 있습니다. 기본 이름은 템플릿 파일의 이름입니다. 예를 들어 azuredeploy.json이라는 템플릿을 배포하면 azuredeploy라는 기본 배포 이름을 만듭니다.

각 배포 이름의 경우 위치는 변경할 수 없습니다. 다른 위치의 이름이 동일한 기존 배포가 있는 경우 하나의 위치에서 배포를 만들 수 없습니다. 예를 들어 centralus에서 이름이 deployment1인 관리 그룹 배포를 만드는 경우 나중에 이름은 deployment1이지만 위치는 westus인 다른 배포를 만들 수 없습니다. 오류 코드 InvalidDeploymentLocation을 수신하게 되면 해당 이름의 이전 배포와 다른 이름이나 동일한 위치를 사용합니다.

배포 범위

관리 그룹에 배포하는 경우 다음에 리소스를 배포할 수 있습니다.

  • 작업의 대상 관리 그룹
  • 테넌트의 다른 관리 그룹
  • 관리 그룹의 구독
  • 관리 그룹의 리소스 그룹
  • 리소스 그룹에 대한 테넌트

확장 리소스의 범위를 배포 대상과 다른 대상으로 지정할 수 있습니다.

템플릿을 배포하는 사용자가 지정된 범위에 액세스할 수 있어야 합니다.

이 섹션에서는 다양한 범위를 지정하는 방법을 보여 줍니다. 단일 템플릿에서 이러한 여러 범위를 결합할 수 있습니다.

대상 관리 그룹에 대한 범위

템플릿의 리소스 섹션 내에 정의된 리소스는 배포 명령에서 관리 그룹에 적용됩니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
    management-group-resources-default
  ],
  "outputs": {}
}

다른 관리 그룹에 대한 범위

다른 관리 그룹을 대상으로 지정하려면 중첩된 배포를 추가하고 scope 속성을 지정합니다. scope 속성을 Microsoft.Management/managementGroups/<mg-name> 형식의 값으로 설정합니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "mgName": {
      "type": "string"
    }
  },
  "variables": {
    "mgId": "[format('Microsoft.Management/managementGroups/{0}', parameters('mgName'))]"
  },
  "resources": [
    {
      "type": "Microsoft.Resources/deployments",
      "apiVersion": "2022-09-01",
      "name": "nestedDeployment",
      "scope": "[variables('mgId')]",
      "location": "eastus",
      "properties": {
        "mode": "Incremental",
        "template": {
          management-group-resources-non-default
        }
      }
    }
  ],
  "outputs": {}
}

구독으로 범위 지정

관리 그룹 내에서 구독을 대상으로 지정할 수도 있습니다. 템플릿을 배포하는 사용자가 지정된 범위에 액세스할 수 있어야 합니다.

관리 그룹 내에서 구독을 대상으로 하려면 중첩된 배포 및 subscriptionId속성을 사용합니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
    {
      "type": "Microsoft.Resources/deployments",
      "apiVersion": "2022-09-01",
      "name": "nestedSub",
      "location": "westus2",
      "subscriptionId": "00000000-0000-0000-0000-000000000000",
      "properties": {
        "mode": "Incremental",
        "template": {
          "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
          "contentVersion": "1.0.0.0",
          "resources": [
            {
              subscription-resources
            }
          ]
        }
      }
    }
  ]
}

리소스 그룹에 대한 범위

관리 그룹 내에서 리소스 그룹을 대상으로 지정할 수도 있습니다. 템플릿을 배포하는 사용자가 지정된 범위에 액세스할 수 있어야 합니다.

관리 그룹 내에서 리소스 그룹을 대상으로 하려면 중첩된 배포를 사용합니다. subscriptionIdresourceGroup 속성을 설정합니다. 중첩된 배포는 리소스 그룹의 위치에 배포되므로 위치를 설정하지 마세요.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
    {
      "type": "Microsoft.Resources/deployments",
      "apiVersion": "2022-09-01",
      "name": "nestedRGDeploy",
      "subscriptionId": "00000000-0000-0000-0000-000000000000",
      "resourceGroup": "demoResourceGroup",
      "properties": {
        "mode": "Incremental",
        "template": {
          "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
          "contentVersion": "1.0.0.0",
          "resources": [
            {
              resource-group-resources
            }
          ]
        }
      }
    }
  ]
}

구독 내에서 리소스 그룹을 만들고 해당 리소스 그룹에 스토리지 계정을 배포하는 데 관리 그룹 배포를 사용하려면 구독 및 리소스 그룹에 배포를 참조하세요.

테넌트로 범위 지정

테넌트에서 리소스를 만들려면 scope/로 설정합니다. 템플릿을 배포하는 사용자에게는 테넌트에서 배포하는 데 필요한 액세스 권한이 있어야 합니다.

중첩된 배포를 사용하려면 scopelocation을 설정합니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
    {
      "type": "Microsoft.Resources/deployments",
      "apiVersion": "2022-09-01",
      "name": "nestedDeployment",
      "location": "centralus",
      "scope": "/",
      "properties": {
        "mode": "Incremental",
        "template": {
          tenant-resources
        }
      }
    }
  ],
  "outputs": {}
}

또는 관리 그룹과 같은 일부 리소스 종류에 대해 범위를 /로 설정할 수 있습니다. 새 관리 그룹을 만드는 방법에 대해서는 다음 섹션에서 설명합니다.

관리 그룹

관리 그룹 배포에서 관리 그룹을 만들려면 관리 그룹에 대한 범위를 /로 설정해야 합니다.

다음 예에서는 루트 관리 그룹에 새 관리 그룹을 만듭니다.

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

다음 예에서는 부모로 지정된 관리 그룹에 새 관리 그룹을 만듭니다. 범위는 /로 설정됩니다.

{
  "$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()))]"
    },
    "parentMG": {
      "type": "string"
    }
  },
  "resources": [
    {
      "name": "[parameters('mgName')]",
      "type": "Microsoft.Management/managementGroups",
      "apiVersion": "2021-04-01",
      "scope": "/",
      "location": "eastus",
      "properties": {
        "details": {
          "parent": {
            "id": "[tenantResourceId('Microsoft.Management/managementGroups', parameters('parentMG'))]"
          }
        }
      }
    }
  ],
  "outputs": {
    "output": {
      "type": "string",
      "value": "[parameters('mgName')]"
    }
  }
}

Abunələr

ARM 템플릿을 사용하여 관리 그룹에서 새 Azure 구독을 만들려면 다음을 참조하세요.

기존 Azure 구독을 새 관리 그룹으로 이동하는 템플릿을 배포하려면 ARM 템플릿에서 구독 이동을 참조하세요.

Azure Policy

관리 그룹에 배포되는 사용자 지정 정책 정의는 관리 그룹의 확장입니다. 사용자 지정 정책 정의의 ID를 가져오려면 Extensionresourceid() 함수를 사용합니다. 기본 제공 정책 정의는 테넌트 수준 리소스입니다. 기본 제공 정책 정의의 ID를 가져오려면 Tenantresourceid() 함수를 사용합니다.

다음 예에서는 관리 그룹 수준에서 정책을 정의하고 할당하는 방법을 보여 줍니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "targetMG": {
      "type": "string",
      "metadata": {
        "description": "Target Management Group"
      }
    },
    "allowedLocations": {
      "type": "array",
      "defaultValue": [
        "australiaeast",
        "australiasoutheast",
        "australiacentral"
      ],
      "metadata": {
        "description": "An array of the allowed locations, all other locations will be denied by the created policy."
      }
    }
  },
  "variables": {
    "mgScope": "[tenantResourceId('Microsoft.Management/managementGroups', parameters('targetMG'))]",
    "policyDefinition": "LocationRestriction"
  },
  "resources": [
    {
      "type": "Microsoft.Authorization/policyDefinitions",
      "name": "[variables('policyDefinition')]",
      "apiVersion": "2020-09-01",
      "properties": {
        "policyType": "Custom",
        "mode": "All",
        "parameters": {
        },
        "policyRule": {
          "if": {
            "not": {
              "field": "location",
              "in": "[parameters('allowedLocations')]"
            }
          },
          "then": {
            "effect": "deny"
          }
        }
      }
    },
    {
      "type": "Microsoft.Authorization/policyAssignments",
      "name": "location-lock",
      "apiVersion": "2020-09-01",
      "dependsOn": [
        "[variables('policyDefinition')]"
      ],
      "properties": {
        "scope": "[variables('mgScope')]",
        "policyDefinitionId": "[extensionResourceId(variables('mgScope'), 'Microsoft.Authorization/policyDefinitions', variables('policyDefinition'))]"
      }
    }
  ]
}

구독 및 리소스 그룹에 배포

관리 그룹 수준 배포에서 관리 그룹 내의 구독을 대상으로 지정할 수 있습니다. 다음 예에서는 구독 내에 리소스 그룹을 만들고 해당 리소스 그룹에 스토리지 계정을 배포합니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "nestedsubId": {
      "type": "string"
    },
    "nestedRG": {
      "type": "string"
    },
    "storageAccountName": {
      "type": "string"
    },
    "nestedLocation": {
      "type": "string"
    }
  },
  "resources": [
    {
      "type": "Microsoft.Resources/deployments",
      "apiVersion": "2021-04-01",
      "name": "nestedSub",
      "location": "[parameters('nestedLocation')]",
      "subscriptionId": "[parameters('nestedSubId')]",
      "properties": {
        "mode": "Incremental",
        "template": {
          "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
          "contentVersion": "1.0.0.0",
          "parameters": {
          },
          "variables": {
          },
          "resources": [
            {
              "type": "Microsoft.Resources/resourceGroups",
              "apiVersion": "2021-04-01",
              "name": "[parameters('nestedRG')]",
              "location": "[parameters('nestedLocation')]"
            }
          ]
        }
      }
    },
    {
      "type": "Microsoft.Resources/deployments",
      "apiVersion": "2021-04-01",
      "name": "nestedRG",
      "subscriptionId": "[parameters('nestedSubId')]",
      "resourceGroup": "[parameters('nestedRG')]",
      "dependsOn": [
        "nestedSub"
      ],
      "properties": {
        "mode": "Incremental",
        "template": {
          "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
          "contentVersion": "1.0.0.0",
          "resources": [
            {
              "type": "Microsoft.Storage/storageAccounts",
              "apiVersion": "2021-04-01",
              "name": "[parameters('storageAccountName')]",
              "location": "[parameters('nestedLocation')]",
              "kind": "StorageV2",
              "sku": {
                "name": "Standard_LRS"
              }
            }
          ]
        }
      }
    }
  ]
}

다음 단계