Skip to content

Commit bbd90a2

Browse files
authored
Merge pull request #107832 from tfitzmac/0316deploy2
update scoped cli commands
2 parents e7d40b4 + b289556 commit bbd90a2

File tree

4 files changed

+62
-26
lines changed

4 files changed

+62
-26
lines changed

articles/azure-resource-manager/templates/deploy-cli.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Deploy resources with Azure CLI and template
33
description: Use Azure Resource Manager and Azure CLI to deploy resources to Azure. The resources are defined in a Resource Manager template.
44
ms.topic: conceptual
5-
ms.date: 10/09/2019
5+
ms.date: 03/16/2020
66
---
77
# Deploy resources with Resource Manager templates and Azure CLI
88

@@ -14,23 +14,39 @@ If you don't have Azure CLI installed, you can use the [Cloud Shell](#deploy-tem
1414

1515
## Deployment scope
1616

17-
You can target your deployment to either an Azure subscription or a resource group within a subscription. In most cases, you'll target deployment to a resource group. Use subscription deployments to apply policies and role assignments across the subscription. You also use subscription deployments to create a resource group and deploy resources to it. Depending on the scope of the deployment, you use different commands.
17+
You can target your deployment to a resource group, subscription, management group, or tenant. In most cases, you'll target deployment to a resource group. To apply policies and role assignments across a larger scope, use subscription, management group, or tenant deployments. When deploying to a subscription, you can create a resource group and deploy resources to it.
1818

19-
To deploy to a **resource group**, use [az group deployment create](/cli/azure/group/deployment?view=azure-cli-latest#az-group-deployment-create):
19+
Depending on the scope of the deployment, you use different commands.
20+
21+
To deploy to a **resource group**, use [az deployment group create](/cli/azure/deployment/group?view=azure-cli-latest#az-deployment-group-create):
2022

2123
```azurecli-interactive
22-
az group deployment create --resource-group <resource-group-name> --template-file <path-to-template>
24+
az deployment group create --resource-group <resource-group-name> --template-file <path-to-template>
2325
```
2426

25-
To deploy to a **subscription**, use [az deployment create](/cli/azure/deployment?view=azure-cli-latest#az-deployment-create):
27+
To deploy to a **subscription**, use [az deployment sub create](/cli/azure/deployment/sub?view=azure-cli-latest#az-deployment-sub-create):
2628

2729
```azurecli-interactive
28-
az deployment create --location <location> --template-file <path-to-template>
30+
az deployment sub create --location <location> --template-file <path-to-template>
2931
```
3032

3133
For more information about subscription level deployments, see [Create resource groups and resources at the subscription level](deploy-to-subscription.md).
3234

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).
35+
To deploy to a **management group**, use [az deployment mg create](/cli/azure/deployment/mg?view=azure-cli-latest#az-deployment-mg-create):
36+
37+
```azurecli-interactive
38+
az deployment mg create --location <location> --template-file <path-to-template>
39+
```
40+
41+
For more information about management group level deployments, see [Create resources at the management group level](deploy-to-management-group.md).
42+
43+
To deploy to a **tenant**, use [az deployment tenant create](/cli/azure/deployment/tenant?view=azure-cli-latest#az-deployment-tenant-create):
44+
45+
```azurecli-interactive
46+
az deployment tenant create --location <location> --template-file <path-to-template>
47+
```
48+
49+
For more information about tenant level deployments, see [Create resources at the tenant level](deploy-to-tenant.md).
3450

3551
The examples in this article use resource group deployments.
3652

articles/azure-resource-manager/templates/deploy-to-management-group.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Deploy resources to management group
33
description: Describes how to deploy resources at the management group scope in an Azure Resource Manager template.
44
ms.topic: conceptual
5-
ms.date: 03/09/2020
5+
ms.date: 03/16/2020
66
---
77

88
# Create resources at the management group level
@@ -40,13 +40,24 @@ https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json
4040

4141
The commands for management group deployments are different than the commands for resource group deployments.
4242

43-
For Azure PowerShell, use [New-AzManagementGroupDeployment](/powershell/module/az.resources/new-azmanagementgroupdeployment).
43+
For Azure CLI, use [az deployment mg create](/cli/azure/deployment/mg?view=azure-cli-latest#az-deployment-mg-create):
44+
45+
```azurecli-interactive
46+
az deployment mg create \
47+
--name demoMGDeployment \
48+
--location WestUS \
49+
--management-group-id myMG \
50+
--template-uri "https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/management-level-deployment/azuredeploy.json"
51+
```
52+
53+
For Azure PowerShell, use [New-AzManagementGroupDeployment](/powershell/module/az.resources/new-azmanagementgroupdeployment).
4454

4555
```azurepowershell-interactive
4656
New-AzManagementGroupDeployment `
47-
-ManagementGroupId "myMG" `
57+
-Name demoMGDeployment `
4858
-Location "West US" `
49-
-TemplateUri https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/management-level-deployment/azuredeploy.json
59+
-ManagementGroupId "myMG" `
60+
-TemplateUri "https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/management-level-deployment/azuredeploy.json"
5061
```
5162

5263
For REST API, use [Deployments - Create At Management Group Scope](/rest/api/resources/deployments/createorupdateatmanagementgroupscope).

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

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Deploy resources to subscription
33
description: Describes how to create a resource group in an Azure Resource Manager template. It also shows how to deploy resources at the Azure subscription scope.
44
ms.topic: conceptual
5-
ms.date: 03/09/2020
5+
ms.date: 03/16/2020
66
---
77

88
# Create resource groups and resources at the subscription level
@@ -45,24 +45,23 @@ https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json
4545

4646
The commands for subscription-level deployments are different than the commands for resource group deployments.
4747

48-
For the Azure CLI, use [az deployment create](/cli/azure/deployment?view=azure-cli-latest#az-deployment-create). The following example deploys a template to create a resource group:
48+
For Azure CLI, use [az deployment sub create](/cli/azure/deployment/sub?view=azure-cli-latest#az-deployment-sub-create). The following example deploys a template to create a resource group:
4949

5050
```azurecli-interactive
51-
az deployment create \
52-
--name demoDeployment \
51+
az deployment sub create \
52+
--name demoSubDeployment \
5353
--location centralus \
54-
--template-uri https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/azure-resource-manager/emptyRG.json \
54+
--template-uri "https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/azure-resource-manager/emptyRG.json" \
5555
--parameters rgName=demoResourceGroup rgLocation=centralus
5656
```
5757

58-
5958
For the PowerShell deployment command, use [New-AzDeployment](/powershell/module/az.resources/new-azdeployment) or **New-AzSubscriptionDeployment**. The following example deploys a template to create a resource group:
6059

6160
```azurepowershell-interactive
6261
New-AzSubscriptionDeployment `
63-
-Name demoDeployment `
62+
-Name demoSubDeployment `
6463
-Location centralus `
65-
-TemplateUri https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/azure-resource-manager/emptyRG.json `
64+
-TemplateUri "https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/azure-resource-manager/emptyRG.json" `
6665
-rgName demoResourceGroup `
6766
-rgLocation centralus
6867
```
@@ -279,10 +278,10 @@ To deploy this template with Azure CLI, use:
279278
# Built-in policy that accepts parameters
280279
definition=$(az policy definition list --query "[?displayName=='Allowed locations'].id" --output tsv)
281280
282-
az deployment create \
281+
az deployment sub create \
283282
--name demoDeployment \
284283
--location centralus \
285-
--template-uri https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/azure-resource-manager/policyassign.json \
284+
--template-uri "https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/azure-resource-manager/policyassign.json" \
286285
--parameters policyDefinitionID=$definition policyName=setLocation policyParameters="{'listOfAllowedLocations': {'value': ['westus']} }"
287286
```
288287

@@ -297,7 +296,7 @@ $policyParams =@{listOfAllowedLocations = @{ value = $locations}}
297296
New-AzSubscriptionDeployment `
298297
-Name policyassign `
299298
-Location centralus `
300-
-TemplateUri https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/azure-resource-manager/policyassign.json `
299+
-TemplateUri "https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/azure-resource-manager/policyassign.json" `
301300
-policyDefinitionID $definition.PolicyDefinitionId `
302301
-policyName setLocation `
303302
-policyParameters $policyParams
@@ -351,10 +350,10 @@ You can [define](../../governance/policy/concepts/definition-structure.md) and a
351350
To create the policy definition in your subscription, and apply it to the subscription, use the following CLI command:
352351

353352
```azurecli
354-
az deployment create \
353+
az deployment sub create \
355354
--name demoDeployment \
356355
--location centralus \
357-
--template-uri https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/azure-resource-manager/policydefineandassign.json
356+
--template-uri "https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/azure-resource-manager/policydefineandassign.json"
358357
```
359358

360359
To deploy this template with PowerShell, use:
@@ -363,7 +362,7 @@ To deploy this template with PowerShell, use:
363362
New-AzSubscriptionDeployment `
364363
-Name definePolicy `
365364
-Location centralus `
366-
-TemplateUri https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/azure-resource-manager/policydefineandassign.json
365+
-TemplateUri "https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/azure-resource-manager/policydefineandassign.json"
367366
```
368367

369368
## Template samples

articles/azure-resource-manager/templates/deploy-to-tenant.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Deploy resources to tenant
33
description: Describes how to deploy resources at the tenant scope in an Azure Resource Manager template.
44
ms.topic: conceptual
5-
ms.date: 03/09/2020
5+
ms.date: 03/16/2020
66
---
77

88
# Create resources at the tenant level
@@ -60,10 +60,20 @@ The principal now has the required permissions to deploy the template.
6060

6161
The commands for tenant deployments are different than the commands for resource group deployments.
6262

63+
For Azure CLI, use [az deployment tenant create](/cli/azure/deployment/tenant?view=azure-cli-latest#az-deployment-tenant-create):
64+
65+
```azurecli-interactive
66+
az deployment tenant create \
67+
--name demoTenantDeployment \
68+
--location WestUS \
69+
--template-uri "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/tenant-level-deployments/new-mg/azuredeploy.json"
70+
```
71+
6372
For Azure PowerShell, use [New-AzTenantDeployment](/powershell/module/az.resources/new-aztenantdeployment).
6473

6574
```azurepowershell-interactive
6675
New-AzTenantDeployment `
76+
-Name demoTenantDeployment `
6777
-Location "West US" `
6878
-TemplateUri "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/tenant-level-deployments/new-mg/azuredeploy.json"
6979
```

0 commit comments

Comments
 (0)