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
description: Determine what changes will happen to your resources before deploying an Azure Resource Manager template.
4
4
author: mumian
5
5
ms.topic: conceptual
6
-
ms.date: 03/05/2020
6
+
ms.date: 04/06/2020
7
7
ms.author: jgao
8
8
---
9
9
# ARM template deployment what-if operation (Preview)
10
10
11
11
Before deploying an Azure Resource Manager (ARM) template, you might want to 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 template. The what-if operation doesn't make any changes to existing resources. Instead, it predicts the changes if the specified template is deployed.
12
12
13
13
> [!NOTE]
14
-
> The what-if operation is currently in preview. To use it, you must [sign up for the preview](https://aka.ms/armtemplatepreviews). As a preview release, the results may sometimes show that a resource will change when actually no change will happen. We're working to reduce these issues, but we need your help. Please report these issues at [https://aka.ms/whatifissues](https://aka.ms/whatifissues).
14
+
> The what-if operation is currently in preview. As a preview release, the results may sometimes show that a resource will change when actually no change will happen. We're working to reduce these issues, but we need your help. Please report these issues at [https://aka.ms/whatifissues](https://aka.ms/whatifissues).
15
15
16
16
You can use the what-if operation with the PowerShell commands or REST API operations.
17
17
18
+
## Install PowerShell module
19
+
20
+
To use what-if in PowerShell, install a preview version of the Az.Resources module from the PowerShell gallery.
21
+
22
+
### Uninstall alpha version
23
+
24
+
If you previously installed an alpha version of the what-if module, uninstall that module. The alpha version was only available to users who signed up for an early preview. If you didn't install that preview, you can skip this section.
25
+
26
+
1. Run PowerShell as administrator
27
+
1. Check your installed versions of the Az.Resources module.
In PowerShell, the output includes color-coded results that help you see the different types of changes.
19
58
20
59

21
60
22
-
The text ouptput is:
61
+
The text output is:
23
62
24
63
```powershell
25
64
Resource and property changes are indicated with these symbols:
@@ -66,11 +105,8 @@ Or, you can use the `-Confirm` switch parameter to preview the changes and get p
66
105
67
106
The preceding commands return a text summary that you can manually inspect. To get an object that you can programmatically inspect for changes, use:
68
107
69
-
*`$results = Get-AzResourceGroupDeploymentWhatIf` for resource group deployments
70
-
*`$results = Get-AzSubscriptionDeploymentWhatIf` or `$results = Get-AzDeploymentWhatIf` for subscription level deployments
71
-
72
-
> [!NOTE]
73
-
> Prior to the release of version 2.0.1-alpha5, you used the `New-AzDeploymentWhatIf` command. This command has been replaced by the `Get-AzDeploymentWhatIf`, `Get-AzResourceGroupDeploymentWhatIf`, and `Get-AzSubscriptionDeploymentWhatIf` commands. If you've used an earlier version, you need to update that syntax. The `-ScopeType` parameter has been removed.
108
+
*`$results = Get-AzResourceGroupDeploymentWhatIfResult` for resource group deployments
109
+
*`$results = Get-AzSubscriptionDeploymentWhatIfResult` or `$results = Get-AzDeploymentWhatIfResult` for subscription level deployments
After the deployment completes, you're ready to test the what-if operation. This time deploy a [template that changes the virtual network](https://github.com/Azure/azure-docs-json-samples/blob/master/azure-resource-manager/what-if/what-if-after.json). It is missing one the original tags, a subnet has been removed, and the address prefix has changed.
203
+
After the deployment completes, you're ready to test the what-if operation. This time deploy a [template that changes the virtual network](https://github.com/Azure/azure-docs-json-samples/blob/master/azure-resource-manager/what-if/what-if-after.json). It's missing one the original tags, a subnet has been removed, and the address prefix has changed.
168
204
169
205
```azurepowershell
170
206
New-AzResourceGroupDeployment `
@@ -208,7 +244,7 @@ Resource changes: 1 to modify.
208
244
209
245
Notice at the top of the output that colors are defined to indicate the type of changes.
210
246
211
-
At the bottom of the output, it shows the tag Owner was deleted. The address prefix changed from 10.0.0.0/16 to 10.0.0.0/15. The subnet named subnet001 was deleted. Remember this changes weren't actually deployed. You see a preview of the changes that will happen if you deploy the template.
247
+
At the bottom of the output, it shows the tag Owner was deleted. The address prefix changed from 10.0.0.0/16 to 10.0.0.0/15. The subnet named subnet001 was deleted. Remember these changes weren't actually deployed. You see a preview of the changes that will happen if you deploy the template.
212
248
213
249
Some of the properties that are listed as deleted won't actually change. Properties can be incorrectly reported as deleted when they aren't in the template, but are automatically set during deployment as default values. This result is considered "noise" in the what-if response. The final deployed resource will have the values set for the properties. As the what-if operation matures, these properties will be filtered out of the result.
214
250
@@ -217,7 +253,7 @@ Some of the properties that are listed as deleted won't actually change. Propert
217
253
Now, let's programmatically evaluate the what-if results by setting the command to a variable.
0 commit comments