With Bicep there is no need to maintain the state of your infrastructure and services, Azure Resource Manager acts as the source of truth. But what happens when you want to go through a pre-flight validation to verify the effect of your template or just to make sure that you won’t fail while deploying?
Azure Resource Manager provides the “What-If “and “Confirm” operations which allows you to preview the effect of a deployment. These operations can be also used with JSON Templates.
What-if operation allows us to preview the effect without first deploying anything.
Confirm operation allows us to preview the effect and being prompted to continue with the deployment.
Using What-If operation with Azure Powershell
New-AzSubscriptionDeployment -Location westeurope -TemplateFile '.\mybiceptemplate.bicep' -WhatIf
The following snippet illustrates the output of the What-If operation. The output also includes color-coded results with the number of affected resources that will help you understand the effect of the deployment.
Using What-If operation with Azure CLI
az deployment sub what-if -l 'westeurope' -n 'mybicepdeployment' -f '.\mybiceptemplate.bicep'
Using Confirm operation with Azure Powershell
New-AzSubscriptionDeployment -Location westeurope -TemplateFile '.\mybiceptemplate.bicep' -Confirm
Using Confirm operation with Azure CLI
az deployment sub create --confirm-with-what-if -l 'westeurope' -n 'bicepdeployment' -f '.\mybiceptemplate.bicep'
Thanks for reading my blog!
Feel free to drop your comment or question below.