Write a Bicep file, preview it with what-if and deploy it

Azure Portal, Hands On15 minutesFreeSteps checked 23 October 2026By Cloud Hands On

In this task you'll deploy a Bicep file with a what-if check first.

Bicep is a simpler language for the same job as ARM templates. A Bicep file is shorter and easier to read than JSON, and Azure turns it into an ARM template for you when you deploy. The Azure CLI in Cloud Shell already understands it.

Before deploying, what-if shows exactly what would be created, changed or deleted, without changing anything. It's the safest habit to learn.

Example. Ironbridge Payments describes each new environment in a Bicep file. Every change goes through a pull request that includes the what-if output, so reviewers can see the effect before anyone deploys.

Before you start

You need: Contributor on the resource group. Time: 15 minutes.

Where to look

  1. Cloud Shell
  2. Bash
  3. Editor

Steps

  1. Open Cloud Shell in Bash. Make a file by typing code main.bicep (or use Editor in the toolbar).
  2. Type a small Bicep file for a free route table, one line at a time:param location string = resourceGroup().location, then resource rt 'Microsoft.Network/routeTables@2024-05-01' = {, then name: 'rt-from-bicep', then location: location, and a closing }. Save it.
  3. Preview it:Type az deployment group what-if --resource-group rg-portal-practice --template-file main.bicep. It lists rt-from-bicep with a + (create). Anything already in the group shows as * (ignore).
  4. Deploy it:Type az deployment group create --resource-group rg-portal-practice --template-file main.bicep.
  5. Add a line inside the braces, such as tags: { env: 'practice' }, save, and run what-if again. This time it shows a ~ (modify) with just the tag change.
  6. Run the create command again, then check the tag on rt-from-bicep in the portal.

Commands

# Preview, then deploy a Bicep file
az deployment group what-if --resource-group rg-portal-practice --template-file main.bicep
az deployment group create --resource-group rg-portal-practice --template-file main.bicep

# Turn Bicep into an ARM template, or the other way round
az bicep build --file main.bicep
az bicep decompile --file template.json

Watch out for

Cost
Deploying is free; route tables are free too. Check what-if for anything paid before creating.
Security
Mark password parameters with @secure() so they aren't shown in logs, and keep Bicep files in a repository with reviews.
Common mistakes
Skipping what-if. Using an old or misspelt API version (the part after @). Forgetting to save the file before running the command.

Clean up

  1. rg-portal-practice
  2. rt-from-bicep
  3. Delete

Delete rt-from-bicep, or the resource group. Remove the file with rm main.bicep.

Words to know

Bicep
A short, readable language for describing Azure resources. It compiles to an ARM template.
What-if
A preview of a deployment's changes, without making them.
Module
A Bicep file used inside another one, to reuse common pieces.

Tick off each step and track your progress in the guide.

Open this task in Azure Portal, Hands On

Keep going