Deploying Templates at the Right Scope and Mode
This lesson explains deployment scopes and commands, incremental and complete modes, what-if and deployment history.
Learning outcomes
After completing this lesson, you will be able to:
- Identify the deployment command for each scope.
- Distinguish between incremental and complete deployment modes.
- Explain how what-if and deployment history help prevent and diagnose problems.
Deployment tools and scopes
The deployment command depends on the target scope. The following table lists the Azure CLI and Azure PowerShell commands for each scope; both accept .json and .bicep files and parameter files.
| Scope | Azure CLI | Azure PowerShell | Typical use |
|---|---|---|---|
| Resource group | az deployment group create | New-AzResourceGroupDeployment | Most workload resources |
| Subscription | az deployment sub create | New-AzSubscriptionDeployment | Resource groups, policy and role assignments, budgets |
| Management group | az deployment mg create | New-AzManagementGroupDeployment | Policies and roles across subscriptions |
| Tenant | az deployment tenant create | New-AzTenantDeployment | Management groups |
az deployment group create \
--resource-group rg-app \
--template-file main.bicep \
--parameters @main.parameters.json vmSize=Standard_D2s_v5In the portal, Deploy a custom template accepts a quickstart template, a template built in the editor, or an uploaded file, and generates a form from its parameters. Template specs store templates as Azure resources with versions and RBAC so that teams deploy approved templates from the portal.
Which deployment command?
Incremental and complete modes
Resource group deployments run in one of two modes. In Incremental mode, the default, Resource Manager creates resources that do not exist and updates those whose properties differ, and it leaves resources that are in the resource group but not in the template untouched. In Complete mode, Resource Manager also deletes resources in the resource group that are not in the template (resources skipped by a false condition are not deleted). Complete mode is selected with --mode Complete.
What-if (az deployment group what-if or the -WhatIf switch) previews the result without making changes, listing resources to create, modify, delete or ignore. It should always be run before a Complete-mode deployment. Deployment stacks are a newer way to manage a set of resources as a unit, with deny settings that protect them.
The following diagram compares Complete and Incremental deployment modes, which explains why a template deployment deleted a manually created key vault.

What happens to each resource?
Deployment history and troubleshooting
Every deployment is stored on the scope's Deployments page with its template, parameters, outputs and per-resource operations. Failed deployments show error codes such as InvalidTemplate (syntax or validation), QuotaExceeded, SkuNotAvailable or RequestDisallowedByPolicy (an Azure Policy Deny). A deployment can be redeployed from history, and resource groups keep up to 800 deployments, deleting the oldest automatically. A deployment name reused in the same scope overwrites the previous history entry.
Reading deployment errors
An unexpected deletion
An engineer deploys a template containing a storage account and an App Service plan to rg-shared, which also contains a key vault created manually. After deployment, the key vault has been deleted. The engineer used the command shown in the runbook. What caused the deletion, and how should it be prevented?
The runbook's command used Complete mode, which deleted the key vault because it was not in the template. Use the default Incremental mode, or add the key vault to the template, and run what-if before deploying to see deletions in advance. A CanNotDelete lock on the key vault would also have blocked the deletion. The key vault can be recovered from soft delete within its retention period.
Which deployment scope is needed to create resource groups from a template?
Show answer
Subscription scope, for example az deployment sub create.
Exam Tips
Remember for the exam
- Incremental is the default and never deletes; Complete deletes resources not in the template.
- Run what-if to preview changes.
- Create resource groups from a template with a subscription-scope deployment.
- RequestDisallowedByPolicy means an Azure Policy assignment blocked the deployment.