Skip to content

Commit e8bdaa8

Browse files
authored
Merge pull request #95214 from tfitzmac/1107mglevel
add management group level
2 parents 15e4d63 + a19f4b2 commit e8bdaa8

File tree

6 files changed

+170
-10
lines changed

6 files changed

+170
-10
lines changed
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
---
2+
title: Create resources at management group - Azure Resource Manager template
3+
description: Describes how to deploy resources at the management group scope in an Azure Resource Manager template.
4+
author: tfitzmac
5+
ms.service: azure-resource-manager
6+
ms.topic: conceptual
7+
ms.date: 11/07/2019
8+
ms.author: tomfitz
9+
---
10+
11+
# Create resources at the management group level
12+
13+
Typically, you deploy Azure resources to a resource group in your Azure subscription. However, you can also create resources at the management group level. You use management group level deployments to take actions that make sense at that level, such as assigning [role-based access control](../role-based-access-control/overview.md) or applying [policies](../governance/policy/overview.md).
14+
15+
Currently, to deploy templates at the management group level, you must use the REST API.
16+
17+
## Supported resources
18+
19+
You can deploy the following resource types at the management group level:
20+
21+
* [deployments](/azure/templates/microsoft.resources/deployments)
22+
* [policyAssignments](/azure/templates/microsoft.authorization/policyassignments)
23+
* [policyDefinitions](/azure/templates/microsoft.authorization/policydefinitions)
24+
* [policySetDefinitions](/azure/templates/microsoft.authorization/policysetdefinitions)
25+
* [roleAssignments](/azure/templates/microsoft.authorization/roleassignments)
26+
* [roleDefinitions](/azure/templates/microsoft.authorization/roledefinitions)
27+
28+
### Schema
29+
30+
The schema you use for management group deployments is different than the schema for resource group deployments.
31+
32+
For templates, use:
33+
34+
```json
35+
https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#
36+
```
37+
38+
For parameter files, use:
39+
40+
```json
41+
https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentParameters.json#
42+
```
43+
44+
## Deployment commands
45+
46+
The command for management group deployments is different than the command for resource group deployments.
47+
48+
For REST API, use [Deployments - Create At Management Group Scope](/rest/api/resources/deployments/createorupdateatmanagementgroupscope).
49+
50+
## Deployment location and name
51+
52+
For management group level deployments, you must provide a location for the deployment. The location of the deployment is separate from the location of the resources you deploy. The deployment location specifies where to store deployment data.
53+
54+
You can provide a name for the deployment, or use the default deployment name. The default name is the name of the template file. For example, deploying a template named **azuredeploy.json** creates a default deployment name of **azuredeploy**.
55+
56+
For each deployment name, the location is immutable. You can't create a deployment in one location when there's an existing deployment with the same name in a different location. If you get the error code `InvalidDeploymentLocation`, either use a different name or the same location as the previous deployment for that name.
57+
58+
## Use template functions
59+
60+
For management group deployments, there are some important considerations when using template functions:
61+
62+
* The [resourceGroup()](resource-group-template-functions-resource.md#resourcegroup) function is **not** supported.
63+
* The [subscription()](resource-group-template-functions-resource.md#subscription) function is **not** supported.
64+
* The [resourceId()](resource-group-template-functions-resource.md#resourceid) function is supported. Use it to get the resource ID for resources that are used at management group level deployments. For example, get the resource ID for a policy definition with `resourceId('Microsoft.Authorization/roleDefinitions/', parameters('roleDefinition'))`. It returns the resource ID in the format `/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}`.
65+
* The [reference()](resource-group-template-functions-resource.md#reference) and [list()](resource-group-template-functions-resource.md#list) functions are supported.
66+
67+
## Create policies
68+
69+
### Define policy
70+
71+
The following example shows how to [define](../governance/policy/concepts/definition-structure.md) a policy at the management group level.
72+
73+
```json
74+
{
75+
"$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#",
76+
"contentVersion": "1.0.0.0",
77+
"parameters": {},
78+
"variables": {},
79+
"resources": [
80+
{
81+
"type": "Microsoft.Authorization/policyDefinitions",
82+
"name": "locationpolicy",
83+
"apiVersion": "2018-05-01",
84+
"properties": {
85+
"policyType": "Custom",
86+
"parameters": {},
87+
"policyRule": {
88+
"if": {
89+
"field": "location",
90+
"equals": "northeurope"
91+
},
92+
"then": {
93+
"effect": "deny"
94+
}
95+
}
96+
}
97+
}
98+
]
99+
}
100+
```
101+
102+
### Assign policy
103+
104+
The following example assigns an existing policy definition to the management group. If the policy takes parameters, provide them as an object. If the policy doesn't take parameters, use the default empty object.
105+
106+
```json
107+
{
108+
"$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#",
109+
"contentVersion": "1.0.0.0",
110+
"parameters": {
111+
"policyDefinitionID": {
112+
"type": "string"
113+
},
114+
"policyName": {
115+
"type": "string"
116+
},
117+
"policyParameters": {
118+
"type": "object",
119+
"defaultValue": {}
120+
}
121+
},
122+
"variables": {},
123+
"resources": [
124+
{
125+
"type": "Microsoft.Authorization/policyAssignments",
126+
"name": "[parameters('policyName')]",
127+
"apiVersion": "2018-03-01",
128+
"properties": {
129+
"policyDefinitionId": "[parameters('policyDefinitionID')]",
130+
"parameters": "[parameters('policyParameters')]"
131+
}
132+
}
133+
]
134+
}
135+
```
136+
137+
138+
139+
## Next steps
140+
141+
* To learn about assigning roles, see [Manage access to Azure resources using RBAC and Azure Resource Manager templates](../role-based-access-control/role-assignments-template.md).
142+
* For an example of deploying workspace settings for Azure Security Center, see [deployASCwithWorkspaceSettings.json](https://github.com/krnese/AzureDeploy/blob/master/ARM/deployments/deployASCwithWorkspaceSettings.json).
143+
* To learn about creating Azure Resource Manager templates, see [Authoring templates](resource-group-authoring-templates.md).
144+
* For a list of the available functions in a template, see [Template functions](resource-group-template-functions.md).

articles/azure-resource-manager/deploy-to-subscription.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Describes how to create a resource group in an Azure Resource Manag
44
author: tfitzmac
55
ms.service: azure-resource-manager
66
ms.topic: conceptual
7-
ms.date: 10/07/2019
7+
ms.date: 11/07/2019
88
ms.author: tomfitz
99
---
1010

@@ -18,7 +18,7 @@ To deploy templates at the subscription level, use Azure CLI, PowerShell, or RES
1818

1919
You can deploy the following resource types at the subscription level:
2020

21-
* [deployments](/azure/templates/microsoft.resources/deployments)
21+
* [deployments](/azure/templates/microsoft.resources/deployments)
2222
* [peerAsns](/azure/templates/microsoft.peering/peerasns)
2323
* [policyAssignments](/azure/templates/microsoft.authorization/policyassignments)
2424
* [policyDefinitions](/azure/templates/microsoft.authorization/policydefinitions)
@@ -31,12 +31,18 @@ You can deploy the following resource types at the subscription level:
3131

3232
The schema you use for subscription-level deployments is different than the schema for resource group deployments.
3333

34-
For the schema, use:
34+
For templates, use:
3535

3636
```json
3737
https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#
3838
```
3939

40+
For parameter files, use:
41+
42+
```json
43+
https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentParameters.json#
44+
```
45+
4046
## Deployment commands
4147

4248
The commands for subscription-level deployments are different than the commands for resource group deployments.
@@ -71,14 +77,14 @@ For subscription level deployments, you must provide a location for the deployme
7177

7278
You can provide a name for the deployment, or use the default deployment name. The default name is the name of the template file. For example, deploying a template named **azuredeploy.json** creates a default deployment name of **azuredeploy**.
7379

74-
For each deployment name, the location is immutable. You can't create a deployment in one location when there's an existing deployment with the same name but different location. If you get the error code `InvalidDeploymentLocation`, either use a different name or the same location as the previous deployment for that name.
80+
For each deployment name, the location is immutable. You can't create a deployment in one location when there's an existing deployment with the same name in a different location. If you get the error code `InvalidDeploymentLocation`, either use a different name or the same location as the previous deployment for that name.
7581

7682
## Use template functions
7783

7884
For subscription-level deployments, there are some important considerations when using template functions:
7985

8086
* The [resourceGroup()](resource-group-template-functions-resource.md#resourcegroup) function is **not** supported.
81-
* The [resourceId()](resource-group-template-functions-resource.md#resourceid) function is supported. Use it to get the resource ID for resources that are used at subscription level deployments. For example, get the resource ID for a policy definition with `resourceId('Microsoft.Authorization/roleDefinitions/', parameters('roleDefinition'))`
87+
* The [resourceId()](resource-group-template-functions-resource.md#resourceid) function is supported. Use it to get the resource ID for resources that are used at subscription level deployments. For example, get the resource ID for a policy definition with `resourceId('Microsoft.Authorization/roleDefinitions/', parameters('roleDefinition'))`. Or, use the [subscriptionResourceId()](resource-group-template-functions-resource.md#subscriptionresourceid) function to get the resource ID for a subscription level resource.
8288
* The [reference()](resource-group-template-functions-resource.md#reference) and [list()](resource-group-template-functions-resource.md#list) functions are supported.
8389

8490
## Create resource groups

articles/azure-resource-manager/resource-group-template-deploy-cli.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ To deploy to a **subscription**, use [az deployment create](/cli/azure/deploymen
3232
az deployment create --location <location> --template-file <path-to-template>
3333
```
3434

35-
Currently, management group deployments are only supported through the REST API. See [Deploy resources with Resource Manager templates and Resource Manager REST API](resource-group-template-deploy-rest.md).
35+
For more information about subscription level deployments, see [Create resource groups and resources at the subscription level](deploy-to-subscription.md).
3636

37-
The examples in this article use resource group deployments. For more information about subscription deployments, see [Create resource groups and resources at the subscription level](deploy-to-subscription.md).
37+
Currently, management group deployments are only supported through the REST API. For more information about management group level deployments, see [Create resources at the management group level](deploy-to-management-group.md).
38+
39+
The examples in this article use resource group deployments.
3840

3941
## Deploy local template
4042

articles/azure-resource-manager/resource-group-template-deploy-rest.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,17 @@ To deploy to a **subscription**, use [Deployments - Create At Subscription Scope
2929
PUT https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}?api-version=2019-05-01
3030
```
3131

32+
For more information about subscription level deployments, see [Create resource groups and resources at the subscription level](deploy-to-subscription.md).
33+
3234
To deploy to a **management group**, use [Deployments - Create At Management Group Scope](/rest/api/resources/deployments/createorupdateatmanagementgroupscope). The request is sent to:
3335

3436
```HTTP
3537
PUT https://management.azure.com/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}?api-version=2019-05-01
3638
```
3739

38-
The examples in this article use resource group deployments. For more information about subscription deployments, see [Create resource groups and resources at the subscription level](deploy-to-subscription.md).
40+
For more information about management group level deployments, see [Create resources at the management group level](deploy-to-management-group.md).
41+
42+
The examples in this article use resource group deployments.
3943

4044
## Deploy with the REST API
4145

articles/azure-resource-manager/resource-group-template-deploy.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ To deploy to a **subscription**, use [New-AzDeployment](/powershell/module/az.re
2828
New-AzDeployment -Location <location> -TemplateFile <path-to-template>
2929
```
3030

31-
Currently, management group deployments are only supported through the REST API. See [Deploy resources with Resource Manager templates and Resource Manager REST API](resource-group-template-deploy-rest.md).
31+
For more information about subscription level deployments, see [Create resource groups and resources at the subscription level](deploy-to-subscription.md).
3232

33-
The examples in this article use resource group deployments. For more information about subscription deployments, see [Create resource groups and resources at the subscription level](deploy-to-subscription.md).
33+
Currently, management group deployments are only supported through the REST API. For more information about management group level deployments, see [Create resources at the management group level](deploy-to-management-group.md).
34+
35+
The examples in this article use resource group deployments.
3436

3537
## Prerequisites
3638

articles/azure-resource-manager/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@
138138
href: resource-group-create-multiple.md
139139
- name: Subscription level resources
140140
href: deploy-to-subscription.md
141+
- name: Management group level resources
142+
href: deploy-to-management-group.md
141143
- name: Deploy templates
142144
items:
143145
- name: Deploy - portal

0 commit comments

Comments
 (0)