Azure Bicep - Preview
Azure Bicep - Preview

Azure Bicep – How to preview the modifications ?

In last few articles, we have been discussing about Azure Bicep. We have seen how to write bicep files and how to deploy the bicep modules. In this article, we are going to have a look at how to preview the modifications before actually deploying a bicep module.


You can use either PowerShell command or Azure CLI Command. In order to use intended commands, please ensure that you have the required tools installed.

  • To use what-if in PowerShell, you must have version 4.2 or later of the Az module.
  • To use what-if in Azure CLI, you must have Azure CLI 2.14.0 or later. If needed, install the latest version of Azure CLI. Please ensure that you have

Create a Bicep File

The code snippet given below shows a bicep file that we are going to use for this demo. This file takes few parameters and then it tries to create a storage account.

PowerShell Commands

We can use the what-if commands to preview the modifications which would be done by a bicep module. Below are the PowerShell commands which can be used for this purpose

  • New-AzResourceGroupDeployment -Whatif for resource group deployments
  • New-AzSubscriptionDeployment -Whatif and New-AzDeployment -Whatif for subscription level deployments

These two commands will not deploy any resource. They will just allow users to preview what would be done if the bicep module specified in the command is deployed.

Alternatively, we can use -Confirm switch. If this switch is used, the command would return a preview, which can be manually inspected. Once confirmed, the file would be promoted to deployment.

  • New-AzResourceGroupDeployment -Confirm for resource group deployments
  • New-AzSubscriptionDeployment -Confirm and New-AzDeployment -Confirm for subscription level deployments

To get an object that you can programmatically inspect for changes, use Get-AzResourceGroupDeploymentWhatIfResult or Get-AzSubscriptionDeploymentWhatIfResult.

Azure CLI Commands

If you want to use Azure CLI, the below mentioned commands can be used to preview the bicep module.

Instead of what-if we can use --confirm-with-what-if switch (or its short form -c) to preview the changes and get prompted to continue with the deployment.

What-If Operation Change Types

The bicep file preview operation may return any of the 6 values mentioned below for each resource

  • Create, this conveys that the resource would be created
  • Modify, this conveys that the resource would be modified
  • Delete, this means that existing resource would be deleted
  • NoChange, this means that there is no change (the resource would be redeployed, but no change in its properties)
  • Ignore, meaning the resource exists and not defined in bicep file. Hence it will not be deployed or modified.
  • Deploy,  it means that resource exists, and is defined in the Bicep file. The resource will be redeployed.


Now, we can try the command. The snapshot given below shows usage of what-if command using Azure CLI. Here, the preview is saying that there would be NoChange. This means that resource exists already and it is also defined in the bicep file. Hence it would be redeployed, but its properties would not change. Then there are three resources mentioned with tag Ignore, meaning that they exist and are not mentioned in the bicep file. Hence they will not be modified and they will also be not be redeployed.

I hope you find this information helpful. Let me know your thoughts.

Leave a ReplyCancel reply