Skip to content

Commit 451ee83

Browse files
authored
Merge pull request #110575 from tfitzmac/0407whatif
change installation instructions
2 parents d7350f5 + 468455b commit 451ee83

File tree

1 file changed

+47
-11
lines changed

1 file changed

+47
-11
lines changed

articles/azure-resource-manager/templates/template-deploy-what-if.md

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,62 @@ title: Template deployment what-if (Preview)
33
description: Determine what changes will happen to your resources before deploying an Azure Resource Manager template.
44
author: mumian
55
ms.topic: conceptual
6-
ms.date: 03/05/2020
6+
ms.date: 04/06/2020
77
ms.author: jgao
88
---
99
# ARM template deployment what-if operation (Preview)
1010

1111
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.
1212

1313
> [!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).
1515
1616
You can use the what-if operation with the PowerShell commands or REST API operations.
1717

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.
28+
29+
```powershell
30+
Get-InstalledModule -Name Az.Resources -AllVersions | select Name,Version
31+
```
32+
33+
1. If you have an installed version with a version number in the format **2.x.x-alpha**, uninstall that version.
34+
35+
```powershell
36+
Uninstall-Module Az.Resources -RequiredVersion 2.0.1-alpha5 -AllowPrerelease
37+
```
38+
39+
1. Unregister the what-if repository that you used to install the preview.
40+
41+
```powershell
42+
Unregister-PSRepository -Name WhatIfRepository
43+
```
44+
45+
### Install preview version
46+
47+
To install the preview module, use:
48+
49+
```powershell
50+
Install-Module Az.Resources -RequiredVersion 1.12.1-preview -AllowPrerelease
51+
```
52+
53+
You're ready to use what-if.
54+
55+
## See results
56+
1857
In PowerShell, the output includes color-coded results that help you see the different types of changes.
1958

2059
![Resource Manager template deployment what-if operation fullresourcepayload and change types](./media/template-deploy-what-if/resource-manager-deployment-whatif-change-types.png)
2160

22-
The text ouptput is:
61+
The text output is:
2362

2463
```powershell
2564
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
66105

67106
The preceding commands return a text summary that you can manually inspect. To get an object that you can programmatically inspect for changes, use:
68107

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
74110

75111
### Azure REST API
76112

@@ -164,7 +200,7 @@ New-AzResourceGroupDeployment `
164200

165201
### Test modification
166202

167-
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.
168204

169205
```azurepowershell
170206
New-AzResourceGroupDeployment `
@@ -208,7 +244,7 @@ Resource changes: 1 to modify.
208244

209245
Notice at the top of the output that colors are defined to indicate the type of changes.
210246

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.
212248

213249
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.
214250

@@ -217,7 +253,7 @@ Some of the properties that are listed as deleted won't actually change. Propert
217253
Now, let's programmatically evaluate the what-if results by setting the command to a variable.
218254

219255
```azurepowershell
220-
$results = Get-AzResourceGroupDeploymentWhatIf `
256+
$results = Get-AzResourceGroupDeploymentWhatIfResult `
221257
-ResourceGroupName ExampleGroup `
222258
-TemplateUri "https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/azure-resource-manager/what-if/what-if-after.json"
223259
```

0 commit comments

Comments
 (0)