Ever hesitated before hitting Enter on a command, wondering what changes it might make? You’re not alone. Whether you’re deploying resources or updating configurations, the fear of unintended consequences can slow you down. That’s why we’re introducing new powerful features in Azure CLI and Azure PowerShell to preview the changes the commands may make: the What if and Export Bicep features.
These capabilities allow you to preview the impact of your commands and allow you to export them as Bicep templates, all before making any changes to your Azure environment. Think of them as your safety net: you can validate actions, confirm resource changes, and even generate reusable infrastructure-as-code templates with confidence.
Currently, these features are in private preview, and we’re excited to share how you can get early access.
Why This Matters
- Reduce risk: Avoid accidental resource deletions or costly misconfigurations.
- Build confidence: Understand exactly what your command will do before execution.
- Accelerate adoption of IaC: Convert CLI commands into Bicep templates automatically.
- Improve productivity: Validate scripts quickly without trial-and-error deployments.
How It Works
What if preview of commands
All you have to do is add the `--what-if` parameter to Azure CLI commands and then the `-DryRun` command to Azure PowerShell commands like below.
Azure CLI:
az storage account create --name "mystorageaccount" --resource-group "myResourceGroup" --location "eastus" --what-if |
Azure PowerShell:
New-AzVirtualNetwork -name MyVNET -ResourceGroupName MyResourceGroup -Location eastus -AddressPrefix "10.0.0.0/16" -DryRun |
Exporting commands to Bicep
To generate bicep from the command you will have to add the `--export-bicep` command with the --what-if parameter to generate a bicep file. The bicep code will be saved under the `~/.azure/whatif` directory on your machine. The command will specific exactly where the file is saved on your machine.
Behind the scenes, AI translates your CLI command into Bicep code, creating a reusable template for future deployments. After generating the Bicep file, the CLI automatically runs a What-If analysis on the Bicep template to show you the expected changes before applying them.
Here is a video of it in action!
Here is another example where there is delete, modify and create actions happening all together.
Private Preview Access
These features are available in private preview. To sign up:
- Visit the aka.ms/PreviewSignupPSCLI
- Submit your request for access.
- Once approved, you’ll receive instructions to download the preview package.
Supported Commands (Private Preview)
Given these features are in a preview we have only added support for a small set of commands for the time being. Here’s a list of commands that will support these features during the private preview:
Azure CLI
- Az vm create
- Az vm update
- az storage account create
- az storage container create
- az storage share create
- az network vnet create
- az network vnet update
- az storage account network-rule add
- az vm disk attach
- az vm disk detach
- az vm nic remove
Azure PowerShell
- New-AzVM
- Update-AzVM
- New-AzStorageAccount
- New-AzRmStorageShare
- New-AzRmStorageContainer
- New-AzVirtualNetwork
- Set-AzVirtualNetwork
- Add-AzStorageAccountNetworkRule
Next Steps
- Sign up for the private preview.
- Install the packages using the upcoming script.
- Start using --what-if, -DryRun, and --export-bicep to make safer, smarter decisions and accelerate your IaC journey.
- Give us feedback on what you think of the feature! At https://aka.ms/PreviewFeedbackWhatIf
Thanks so much!
Steven Bucher
PM for Azure Client Tools