Skip to content

Commit 9b134be

Browse files
committed
update
1 parent 53a31e1 commit 9b134be

5 files changed

+103
-9
lines changed
Loading
Loading

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

Lines changed: 103 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,19 @@ The what-if operation lists six different types of changes:
3535

3636
- **Deploy**: The resource exists, and is defined in the template. 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`.
3737

38-
## Deployment scope
38+
## What-if commands
3939

40-
You can use the what-if operation for deployments at either the subscription or resource group level.
40+
You can use the what-if operation for deployments at either the subscription or resource group level.
4141

4242
For PowerShell, use:
4343

44-
* **Get-AzResourceGroupDeploymentWhatIf** for resource group deployments
45-
* **Get-AzSubscriptionDeploymentWhatIf** or **Get-AzDeploymentWhatIf** for subscription level deployments
44+
* `Get-AzResourceGroupDeploymentWhatIf` for resource group deployments
45+
* `Get-AzSubscriptionDeploymentWhatIf` or `Get-AzDeploymentWhatIf` for subscription level deployments
46+
47+
> [!NOTE]
48+
> Prior to the release of version 2.0.1-alpha5, you used the `New-AzDeploymentWhatIf` command. This command has been replaced by the `Get-Az*DeploymentWhatIf` syntax. If you've used an earlier version, you need to update those commands.
49+
50+
You can also run the what-if operation from the `New-AzResourceGroupDeployment`, `New-AzSubscriptionDeployment` and `New-AzDeployment` commands. Use the `-Whatif` switch parameter to run the what-if command. Use the `-Confirm` switch parameter to first run what-if and then have the option to complete the deployment.
4651

4752
For REST API, use:
4853

@@ -57,15 +62,41 @@ This article demonstrates resource group deployments.
5762

5863
You can control the level of detail that is returned about the predicted changes. Set the **ResultFormat** parameter to **FullResourcePayloads** to get a list of resources what will change and details about the properties that will change. Set the **ResultFormat** parameter to **ResourceIdOnly** to get a list of resources that will change. The default value is `FullResourcePayloads`.
5964

60-
The following screenshots show the two different output formats:
65+
The following results show the two different output formats:
6166

6267
- Full resource payloads
6368

64-
![Resource Manager template deployment what-if operation fullresourcepayloads output](./media/template-deploy-what-if/resource-manager-deployment-whatif-output-fullresourcepayload.png)
69+
```powershell
70+
Resource and property changes are indicated with these symbols:
71+
- Delete
72+
~ Modify
73+
74+
The deployment will update the following scope:
75+
76+
Scope: /subscriptions/./resourceGroups/ExampleGroup
77+
78+
~ Microsoft.Storage/storageAccounts/storez2wlfuvcm4awc [2019-04-01]
79+
- properties.accessTier: "Hot"
80+
~ properties.supportsHttpsTrafficOnly: true => "true"
81+
~ sku.name: "Standard_LRS" => "Standard_GRS"
82+
83+
Resource changes: 1 to modify.
84+
```
6585

6686
- Resource ID only
6787

68-
![Resource Manager template deployment what-if operation resourceidonly output](./media/template-deploy-what-if/resource-manager-deployment-whatif-output-resourceidonly.png)
88+
```powershell
89+
Resource and property changes are indicated with this symbol:
90+
! Deploy
91+
92+
The deployment will update the following scope:
93+
94+
Scope: /subscriptions/./resourceGroups/ExampleGroup
95+
96+
! Microsoft.Storage/storageAccounts/storez2wlfuvcm4awc
97+
98+
Resource changes: 1 to deploy.
99+
```
69100

70101
## Run what-if operation
71102

@@ -127,8 +158,7 @@ Some of the properties that are listed as deleted won't actually change. In the
127158
The what-if operation supports using [deployment mode](deployment-modes.md). When set to complete mode, resources not in the template are deleted. The following example deploys a [template that has no resources defined](https://github.com/Azure/azure-docs-json-samples/blob/master/empty-template/azuredeploy.json) in complete mode.
128159

129160
```azurepowershell-interactive
130-
New-AzDeploymentWhatIf `
131-
-ScopeType ResourceGroup `
161+
Get-AzResourceGroupDeploymentWhatIf `
132162
-ResourceGroupName ExampleGroup `
133163
-TemplateUri "https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/empty-template/azuredeploy.json" `
134164
-Mode Complete
@@ -138,8 +168,72 @@ Because no resources are defined in the template and the deployment mode is set
138168

139169
![Resource Manager template deployment what-if operation output deployment mode complete](./media/template-deploy-what-if/resource-manager-deployment-whatif-output-mode-complete.png)
140170

171+
The text output is:
172+
173+
```powershell
174+
Resource and property changes are indicated with this symbol:
175+
- Delete
176+
177+
The deployment will update the following scope:
178+
179+
Scope: /subscriptions/./resourceGroups/ExampleGroup
180+
181+
- Microsoft.Storage/storageAccounts/storez2wlfuvcm4awc
182+
183+
id: "/subscriptions/./resourceGroups/ExampleGroup/providers/Microsoft.St
184+
orage/storageAccounts/storez2wlfuvcm4awc"
185+
kind: "StorageV2"
186+
location: "centralus"
187+
name: "storez2wlfuvcm4awc"
188+
sku.name: "Standard_LRS"
189+
sku.tier: "Standard"
190+
type: "Microsoft.Storage/storageAccounts"
191+
192+
Resource changes: 1 to delete.
193+
```
194+
141195
It's important to remember what-if makes no actual changes. The storage account still exists in your resource group.
142196

197+
## Confirm before deployment
198+
199+
To preview changes before deploying a template, use the `-Confirm` switch parameter with the deployment command. If the changes are as you expected, you can then confirm that you want the deployment to complete. The following command allows you to preview changes before the template is deployed.
200+
201+
```powershell
202+
New-AzResourceGroupDeployment `
203+
-ResourceGroupName ExampleGroup `
204+
-TemplateUri "https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/empty-template/azuredeploy.json" `
205+
-Mode Complete `
206+
-Confirm
207+
```
208+
209+
You see the expected changes and can confirm that you want the deployment to run.
210+
211+
```powershell
212+
Resource and property changes are indicated with this symbol:
213+
- Delete
214+
215+
The deployment will update the following scope:
216+
217+
Scope: /subscriptions/./resourceGroups/ExampleGroup
218+
219+
- Microsoft.Storage/storageAccounts/storez2wlfuvcm4awc
220+
221+
id:
222+
"/subscriptions/./resourceGroups/ExampleGroup/providers/Microsoft.Storage/storageAcc
223+
ounts/storez2wlfuvcm4awc"
224+
kind: "StorageV2"
225+
location: "centralus"
226+
name: "storez2wlfuvcm4awc"
227+
sku.name: "Standard_LRS"
228+
sku.tier: "Standard"
229+
type: "Microsoft.Storage/storageAccounts"
230+
231+
Resource changes: 1 to delete.
232+
233+
Are you sure you want to execute the deployment?
234+
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
235+
```
236+
143237
## Next steps
144238

145239
- If you notice incorrect results from the preview release of what-if, please report the issues at [https://aka.ms/whatifissues](https://aka.ms/whatifissues).

0 commit comments

Comments
 (0)