|
1 | 1 | --- |
2 | | -title: Deploy resources cross subscription & resource group |
3 | | -description: Shows how to target more than one Azure subscription and resource group during deployment. |
| 2 | +title: Deploy resources across scopes |
| 3 | +description: Shows how to target more than one scope during a deployment. The scope can be a tenant, management groups, subscriptions, and resource groups. |
4 | 4 | ms.topic: conceptual |
5 | | -ms.date: 05/18/2020 |
| 5 | +ms.date: 07/28/2020 |
6 | 6 | --- |
7 | 7 |
|
8 | | -# Deploy Azure resources across subscriptions or resource groups |
| 8 | +# Deploy Azure resources across scopes |
9 | 9 |
|
10 | | -Resource Manager enables you to deploy to more than one resource group in a single deployment. You use nested templates to specify resource groups that are different than the resource group in the deployment operation. The resource groups can exist in different subscriptions. |
| 10 | +With Azure Resource Manager templates (ARM templates), you can deploy to more than one scope in a single deployment. The available scopes are a tenant, management groups, subscriptions, and resource groups. For example, you can deploy resources to one resource group, and in the same template deploy resources to another resource group. Or, you can deploy resources to a management group and also deploy resources to a resource group within that management group. |
11 | 11 |
|
12 | | -> [!NOTE] |
13 | | -> You can deploy to **800 resource groups** in a single deployment. Typically, this limitation means you can deploy to one resource group specified for the parent template, and up to 799 resource groups in nested or linked deployments. However, if your parent template contains only nested or linked templates and does not itself deploy any resources, then you can include up to 800 resource groups in nested or linked deployments. |
| 12 | +You use [nested or linked templates](linked-templates.md) to specify scopes that are different than the primary scope for the deployment operation. |
| 13 | + |
| 14 | +## Available scopes |
14 | 15 |
|
15 | | -## Specify subscription and resource group |
| 16 | +The scope that you use for the deployment operation determines which other scopes are available. You can deploy to the [tenant](deploy-to-tenant.md), [management group](deploy-to-management-group.md), [subscription](deploy-to-subscription), or [resource group](deploy-powershell.md). From the primary deployment level, you can't go up levels in the hierarchy. For example, if you deploy to a subscription, you can't step up a level to deploy resources to a management group. However, you can deploy to the management group and step down levels to deploy to a subscription or resource group. |
16 | 17 |
|
17 | | -To target a resource group that is different than the one for parent template, use a [nested or linked template](linked-templates.md). Within the deployment resource type, specify values for the subscription ID and resource group that you want the nested template to deploy to. |
| 18 | +For every scope, the user deploying the template must have the required permissions to create resources. |
| 19 | + |
| 20 | +## Cross resource groups |
| 21 | + |
| 22 | +To target a resource group that is different than the one for parent template, use a [nested or linked template](linked-templates.md). Within the deployment resource type, specify values for the subscription ID and resource group that you want the nested template to deploy to. The resource groups can exist in different subscriptions. |
18 | 23 |
|
19 | 24 | :::code language="json" source="~/resourcemanager-templates/azure-resource-manager/crosssubscription.json" range="38-43" highlight="5-6"::: |
20 | 25 |
|
21 | 26 | If you don't specify the subscription ID or resource group, the subscription and resource group from the parent template are used. All the resource groups must exist before running the deployment. |
22 | 27 |
|
23 | | -The account that deploys the template must have permission to deploy to the specified subscription ID. If the specified subscription exists in a different Azure Active Directory tenant, you must [add guest users from another directory](../../active-directory/b2b/what-is-b2b.md). |
| 28 | +> [!NOTE] |
| 29 | +> You can deploy to **800 resource groups** in a single deployment. Typically, this limitation means you can deploy to one resource group specified for the parent template, and up to 799 resource groups in nested or linked deployments. However, if your parent template contains only nested or linked templates and does not itself deploy any resources, then you can include up to 800 resource groups in nested or linked deployments. |
24 | 30 |
|
25 | 31 | The following example deploys two storage accounts. The first storage account is deployed to the resource group specified in the deployment operation. The second storage account is deployed to the resource group specified in the `secondResourceGroup` and `secondSubscriptionID` parameters: |
26 | 32 |
|
@@ -114,9 +120,17 @@ az deployment group create \ |
114 | 120 |
|
115 | 121 | --- |
116 | 122 |
|
117 | | -## Use functions |
| 123 | +## Cross subscription, management group, and tenant |
| 124 | + |
| 125 | +When specifying different scopes for subscription, management group and tenant level deployments, you use nested deployments like the example for resource groups. The properties that you use for specifying scope can differ. Those scenarios are covered in the articles about the levels of deployments. For more information, see: |
| 126 | + |
| 127 | +* [Create resource groups and resources at the subscription level](deploy-to-subscription.md) |
| 128 | +* [Create resources at the management group level](deploy-to-management-group.md) |
| 129 | +* [Create resources at the tenant level](deploy-to-tenant.md) |
118 | 130 |
|
119 | | -The [resourceGroup()](template-functions-resource.md#resourcegroup) and [subscription()](template-functions-resource.md#subscription) functions resolve differently based on how you specify the template. When you link to an external template, the functions always resolve to the scope for that template. When you nest a template within a parent template, use the `expressionEvaluationOptions` property to specify whether the functions resolve to the resource group and subscription for the parent template or the nested template. Set the property to `inner` to resolve to the scope for the nested template. Set the property to `outer` to resolve to the scope of the parent template. |
| 131 | +## How functions resolve in scopes |
| 132 | + |
| 133 | +When you deploy to more than one scope, the [resourceGroup()](template-functions-resource.md#resourcegroup) and [subscription()](template-functions-resource.md#subscription) functions resolve differently based on how you specify the template. When you link to an external template, the functions always resolve to the scope for that template. When you nest a template within a parent template, use the `expressionEvaluationOptions` property to specify whether the functions resolve to the resource group and subscription for the parent template or the nested template. Set the property to `inner` to resolve to the scope for the nested template. Set the property to `outer` to resolve to the scope of the parent template. |
120 | 134 |
|
121 | 135 | The following table shows whether the functions resolve to the parent or embedded resource group and subscription. |
122 | 136 |
|
@@ -197,6 +211,8 @@ The output from the preceding example is: |
197 | 211 |
|
198 | 212 | --- |
199 | 213 |
|
| 214 | + |
| 215 | + |
200 | 216 | ## Next steps |
201 | 217 |
|
202 | 218 | * To understand how to define parameters in your template, see [Understand the structure and syntax of Azure Resource Manager templates](template-syntax.md). |
|
0 commit comments