You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/bicep/deploy-what-if.md
+46-35Lines changed: 46 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,10 @@ title: Bicep deployment what-if
3
3
description: Determine what changes will happen to your resources before deploying a Bicep file.
4
4
author: tfitzmac
5
5
ms.topic: conceptual
6
-
ms.date: 07/11/2022
6
+
ms.date: 02/15/2023
7
7
ms.author: tomfitz
8
8
---
9
+
9
10
# Bicep deployment what-if operation
10
11
11
12
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
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
+
21
32
## Install Azure PowerShell module
22
33
23
34
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.
78
89
79
90
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.
80
91
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
83
94
84
95
You can use the `-Confirm` switch parameter to preview the changes and get prompted to continue with the deployment.
85
96
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
88
99
89
100
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).
90
101
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
93
104
94
105
### Azure CLI
95
106
96
107
To preview changes before deploying a Bicep file, use:
97
108
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
102
113
103
114
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:
104
115
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).
For example, use `az deployment group create --confirm-with-what-if` or `-c` for resource group deployments.
111
122
@@ -117,28 +128,28 @@ If you want to return the results without colors, open your [Azure CLI configura
117
128
118
129
For REST API, use:
119
130
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.
124
135
125
136
## Change types
126
137
127
138
The what-if operation lists six different types of changes:
128
139
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`.
135
146
136
147
## Result format
137
148
138
149
You control the level of detail that is returned about the predicted changes. You have two options:
139
150
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
142
153
143
154
The default value is **FullResourcePayloads**.
144
155
@@ -148,7 +159,7 @@ For Azure CLI, use the `--result-format` parameter.
148
159
149
160
The following results show the two different output formats:
150
161
151
-
* Full resource payloads
162
+
- Full resource payloads
152
163
153
164
```powershell
154
165
Resource and property changes are indicated with these symbols:
@@ -177,7 +188,7 @@ The following results show the two different output formats:
177
188
Resource changes: 1 to modify.
178
189
```
179
190
180
-
* Resource ID only
191
+
- Resource ID only
181
192
182
193
```powershell
183
194
Resource and property changes are indicated with this symbol:
You can use the what-if operation through the Azure SDKs.
407
418
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-).
409
420
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).
411
422
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).
413
424
414
425
## Next steps
415
426
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