Skip to content

Commit 20ad822

Browse files
Merge pull request #227344 from mumian/0214-whatif-limits
what if nested template limit
2 parents e115bee + 5330bb7 commit 20ad822

File tree

2 files changed

+83
-62
lines changed

2 files changed

+83
-62
lines changed

articles/azure-resource-manager/bicep/deploy-what-if.md

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ title: Bicep deployment what-if
33
description: Determine what changes will happen to your resources before deploying a Bicep file.
44
author: tfitzmac
55
ms.topic: conceptual
6-
ms.date: 07/11/2022
6+
ms.date: 02/15/2023
77
ms.author: tomfitz
88
---
9+
910
# Bicep deployment what-if operation
1011

1112
Before deploying a Bicep file, you can preview the changes that will happen. Azure Resource Manager provides the what-if operation to let you see how resources will change if you deploy the Bicep file. The what-if operation doesn't make any changes to existing resources. Instead, it predicts the changes if the specified Bicep file is deployed.
@@ -18,6 +19,16 @@ If you would rather learn about the what-if operation through step-by-step guida
1819

1920
[!INCLUDE [permissions](../../../includes/template-deploy-permissions.md)]
2021

22+
## What-if limits
23+
24+
What-if expands nested templates until these limits are reached:
25+
26+
- 500 nested templates.
27+
- 800 resource groups in a cross resource-group deployment.
28+
- 5 minutes taken for expanding the nested templates.
29+
30+
When one of the limits is reached, the remaining resources' [change type](#change-types) is set to **Ignore**.
31+
2132
## Install Azure PowerShell module
2233

2334
To use what-if in PowerShell, you must have version **4.2 or later of the Az module**.
@@ -78,34 +89,34 @@ Resource changes: 1 to modify.
7889

7990
To preview changes before deploying a Bicep file, use [New-AzResourceGroupDeployment](/powershell/module/az.resources/new-azresourcegroupdeployment) or [New-AzSubscriptionDeployment](/powershell/module/az.resources/new-azdeployment). Add the `-Whatif` switch parameter to the deployment command.
8091

81-
* `New-AzResourceGroupDeployment -Whatif` for resource group deployments
82-
* `New-AzSubscriptionDeployment -Whatif` and `New-AzDeployment -Whatif` for subscription level deployments
92+
- `New-AzResourceGroupDeployment -Whatif` for resource group deployments
93+
- `New-AzSubscriptionDeployment -Whatif` and `New-AzDeployment -Whatif` for subscription level deployments
8394

8495
You can use the `-Confirm` switch parameter to preview the changes and get prompted to continue with the deployment.
8596

86-
* `New-AzResourceGroupDeployment -Confirm` for resource group deployments
87-
* `New-AzSubscriptionDeployment -Confirm` and `New-AzDeployment -Confirm` for subscription level deployments
97+
- `New-AzResourceGroupDeployment -Confirm` for resource group deployments
98+
- `New-AzSubscriptionDeployment -Confirm` and `New-AzDeployment -Confirm` for subscription level deployments
8899

89100
The preceding commands return a text summary that you can manually inspect. To get an object that you can programmatically inspect for changes, use [Get-AzResourceGroupDeploymentWhatIfResult](/powershell/module/az.resources/get-azresourcegroupdeploymentwhatifresult) or [Get-AzSubscriptionDeploymentWhatIfResult](/powershell/module/az.resources/get-azdeploymentwhatifresult).
90101

91-
* `$results = Get-AzResourceGroupDeploymentWhatIfResult` for resource group deployments
92-
* `$results = Get-AzSubscriptionDeploymentWhatIfResult` or `$results = Get-AzDeploymentWhatIfResult` for subscription level deployments
102+
- `$results = Get-AzResourceGroupDeploymentWhatIfResult` for resource group deployments
103+
- `$results = Get-AzSubscriptionDeploymentWhatIfResult` or `$results = Get-AzDeploymentWhatIfResult` for subscription level deployments
93104

94105
### Azure CLI
95106

96107
To preview changes before deploying a Bicep file, use:
97108

98-
* [az deployment group what-if](/cli/azure/deployment/group#az-deployment-group-what-if) for resource group deployments
99-
* [az deployment sub what-if](/cli/azure/deployment/sub#az-deployment-sub-what-if) for subscription level deployments
100-
* [az deployment mg what-if](/cli/azure/deployment/mg#az-deployment-mg-what-if) for management group deployments
101-
* [az deployment tenant what-if](/cli/azure/deployment/tenant#az-deployment-tenant-what-if) for tenant deployments
109+
- [az deployment group what-if](/cli/azure/deployment/group#az-deployment-group-what-if) for resource group deployments
110+
- [az deployment sub what-if](/cli/azure/deployment/sub#az-deployment-sub-what-if) for subscription level deployments
111+
- [az deployment mg what-if](/cli/azure/deployment/mg#az-deployment-mg-what-if) for management group deployments
112+
- [az deployment tenant what-if](/cli/azure/deployment/tenant#az-deployment-tenant-what-if) for tenant deployments
102113

103114
You can use the `--confirm-with-what-if` switch (or its short form `-c`) to preview the changes and get prompted to continue with the deployment. Add this switch to:
104115

105-
* [az deployment group create](/cli/azure/deployment/group#az-deployment-group-create)
106-
* [az deployment sub create](/cli/azure/deployment/sub#az-deployment-sub-create).
107-
* [az deployment mg create](/cli/azure/deployment/mg#az-deployment-mg-create)
108-
* [az deployment tenant create](/cli/azure/deployment/tenant#az-deployment-tenant-create)
116+
- [az deployment group create](/cli/azure/deployment/group#az-deployment-group-create)
117+
- [az deployment sub create](/cli/azure/deployment/sub#az-deployment-sub-create).
118+
- [az deployment mg create](/cli/azure/deployment/mg#az-deployment-mg-create)
119+
- [az deployment tenant create](/cli/azure/deployment/tenant#az-deployment-tenant-create)
109120

110121
For example, use `az deployment group create --confirm-with-what-if` or `-c` for resource group deployments.
111122

@@ -117,28 +128,28 @@ If you want to return the results without colors, open your [Azure CLI configura
117128

118129
For REST API, use:
119130

120-
* [Deployments - What If](/rest/api/resources/deployments/whatif) for resource group deployments
121-
* [Deployments - What If At Subscription Scope](/rest/api/resources/deployments/whatifatsubscriptionscope) for subscription deployments
122-
* [Deployments - What If At Management Group Scope](/rest/api/resources/deployments/whatifatmanagementgroupscope) for management group deployments
123-
* [Deployments - What If At Tenant Scope](/rest/api/resources/deployments/whatifattenantscope) for tenant deployments.
131+
- [Deployments - What If](/rest/api/resources/deployments/whatif) for resource group deployments
132+
- [Deployments - What If At Subscription Scope](/rest/api/resources/deployments/whatifatsubscriptionscope) for subscription deployments
133+
- [Deployments - What If At Management Group Scope](/rest/api/resources/deployments/whatifatmanagementgroupscope) for management group deployments
134+
- [Deployments - What If At Tenant Scope](/rest/api/resources/deployments/whatifattenantscope) for tenant deployments.
124135

125136
## Change types
126137

127138
The what-if operation lists six different types of changes:
128139

129-
* **Create**: The resource doesn't currently exist but is defined in the Bicep file. The resource will be created.
130-
* **Delete**: This change type only applies when using [complete mode](../templates/deployment-modes.md) for JSON template deployment. The resource exists, but isn't defined in the Bicep file. With complete mode, the resource will be deleted. Only resources that [support complete mode deletion](../templates/deployment-complete-mode-deletion.md) are included in this change type.
131-
* **Ignore**: The resource exists, but isn't defined in the Bicep file. The resource won't be deployed or modified.
132-
* **NoChange**: The resource exists, and is defined in the Bicep file. The resource will be redeployed, but the properties of the resource won't change. This change type is returned when [ResultFormat](#result-format) is set to `FullResourcePayloads`, which is the default value.
133-
* **Modify**: The resource exists, and is defined in the Bicep file. The resource will be redeployed, and the properties of the resource will change. This change type is returned when [ResultFormat](#result-format) is set to `FullResourcePayloads`, which is the default value.
134-
* **Deploy**: The resource exists, and is defined in the Bicep file. The resource will be redeployed. The properties of the resource may or may not change. The operation returns this change type when it doesn't have enough information to determine if any properties will change. You only see this condition when [ResultFormat](#result-format) is set to `ResourceIdOnly`.
140+
- **Create**: The resource doesn't currently exist but is defined in the Bicep file. The resource will be created.
141+
- **Delete**: This change type only applies when using [complete mode](../templates/deployment-modes.md) for JSON template deployment. The resource exists, but isn't defined in the Bicep file. With complete mode, the resource will be deleted. Only resources that [support complete mode deletion](../templates/deployment-complete-mode-deletion.md) are included in this change type.
142+
- **Ignore**: The resource exists, but isn't defined in the Bicep file. The resource won't be deployed or modified. When you reach the limits for expanding nested templates, you will encounter this change type. See [What-if limits](#what-if-limits).
143+
- **NoChange**: The resource exists, and is defined in the Bicep file. The resource will be redeployed, but the properties of the resource won't change. This change type is returned when [ResultFormat](#result-format) is set to `FullResourcePayloads`, which is the default value.
144+
- **Modify**: The resource exists, and is defined in the Bicep file. The resource will be redeployed, and the properties of the resource will change. This change type is returned when [ResultFormat](#result-format) is set to `FullResourcePayloads`, which is the default value.
145+
- **Deploy**: The resource exists, and is defined in the Bicep file. The resource will be redeployed. The properties of the resource may or may not change. The operation returns this change type when it doesn't have enough information to determine if any properties will change. You only see this condition when [ResultFormat](#result-format) is set to `ResourceIdOnly`.
135146

136147
## Result format
137148

138149
You control the level of detail that is returned about the predicted changes. You have two options:
139150

140-
* **FullResourcePayloads** - returns a list of resources that will change and details about the properties that will change
141-
* **ResourceIdOnly** - returns a list of resources that will change
151+
- **FullResourcePayloads** - returns a list of resources that will change and details about the properties that will change
152+
- **ResourceIdOnly** - returns a list of resources that will change
142153

143154
The default value is **FullResourcePayloads**.
144155

@@ -148,7 +159,7 @@ For Azure CLI, use the `--result-format` parameter.
148159

149160
The following results show the two different output formats:
150161

151-
* Full resource payloads
162+
- Full resource payloads
152163

153164
```powershell
154165
Resource and property changes are indicated with these symbols:
@@ -177,7 +188,7 @@ The following results show the two different output formats:
177188
Resource changes: 1 to modify.
178189
```
179190

180-
* Resource ID only
191+
- Resource ID only
181192

182193
```powershell
183194
Resource and property changes are indicated with this symbol:
@@ -405,14 +416,14 @@ Remove-AzResourceGroup -Name ExampleGroup
405416

406417
You can use the what-if operation through the Azure SDKs.
407418

408-
* For Python, use [what-if](/python/api/azure-mgmt-resource/azure.mgmt.resource.resources.v2019_10_01.operations.deploymentsoperations#what-if-resource-group-name--deployment-name--properties--location-none--custom-headers-none--raw-false--polling-true----operation-config-).
419+
- For Python, use [what-if](/python/api/azure-mgmt-resource/azure.mgmt.resource.resources.v2019_10_01.operations.deploymentsoperations#what-if-resource-group-name--deployment-name--properties--location-none--custom-headers-none--raw-false--polling-true----operation-config-).
409420

410-
* For Java, use [DeploymentWhatIf Class](/java/api/com.azure.resourcemanager.resources.models.deploymentwhatif).
421+
- For Java, use [DeploymentWhatIf Class](/java/api/com.azure.resourcemanager.resources.models.deploymentwhatif).
411422

412-
* For .NET, use [DeploymentWhatIf Class](/dotnet/api/microsoft.azure.management.resourcemanager.models.deploymentwhatif).
423+
- For .NET, use [DeploymentWhatIf Class](/dotnet/api/microsoft.azure.management.resourcemanager.models.deploymentwhatif).
413424

414425
## Next steps
415426

416-
* To use the what-if operation in a pipeline, see [Test ARM templates with What-If in a pipeline](https://4bes.nl/2021/03/06/test-arm-templates-with-what-if/).
417-
* If you notice incorrect results from the what-if operation, please report the issues at [https://aka.ms/whatifissues](https://aka.ms/whatifissues).
418-
* For a Learn module that demonstrates using what-if, see [Preview changes and validate Azure resources by using what-if and the ARM template test toolkit](/training/modules/arm-template-test/).
427+
- To use the what-if operation in a pipeline, see [Test ARM templates with What-If in a pipeline](https://4bes.nl/2021/03/06/test-arm-templates-with-what-if/).
428+
- If you notice incorrect results from the what-if operation, please report the issues at [https://aka.ms/whatifissues](https://aka.ms/whatifissues).
429+
- For a Learn module that demonstrates using what-if, see [Preview changes and validate Azure resources by using what-if and the ARM template test toolkit](/training/modules/arm-template-test/).

0 commit comments

Comments
 (0)