Imagine one of your team mates gives you an Azure ARM template to deploy an NSG with few rules in it.

image-left image-left

Things are going great, and suddenly the guy who handed over the ARM template realizes he had overlooked something - but he promises it was something very minor and asks you to redeploy the template

image-left image-left

Well, now you can - Enter WHAT-IF (whatif) commands for Azure ARM template deployments is in preview. If you have ever worked with Terraform’s Plan feature this is on the same lines. So enough talk let’s see how to get started with this.


  • You must have PowerShell 6.x or PowerShell 7.x (Powershell Core) - does not work on 5.x

  • Run this command to enable preview release :

    Install-Module Az.Resources -RequiredVersion 1.12.1-preview -AllowPrerelease

Step 1 -

Create a new deployment using the template provided, this creates a Network Security Group with certain rules. Nothing fancy here just regular deployment of an ARM template

$rgname = "MyNSG-rg"

New-AzResourceGroup -Name $rgname -Location eastus

New-AzResourceGroupDeployment -ResourceGroupName $rgname-TemplateUri ""

Step 2 -

We now received the updated ARM template from our teammate (with the so called “minor” change). With the new “What-If” functionality lets run the following command to see what really changed.

New-AzResourceGroupDeployment -Whatif -ResourceGroupName $rgname -TemplateUri ""

You now see the following output



Well as you can see, this now makes it super easy to see what could potentially change by deploying your ARM template, hey - it’s even color coded and there is a tiny symbol which makes it readable - how cool is that - Green for create, Orangeish - for deletions and Purple for modifications.


Check out the official docs on more change types and don’t forget to report any issues

Leave a comment