Azure Bicep Conditions Loops and What-If Deployments
Use Bicep conditional expressions, for-loops, and what-if analysis to dynamically deploy and preview Azure infrastructure changes.

Lab overview
Real-world infrastructure rarely follows a one-size-fits-all pattern. Different environments need different resources, and teams need to preview changes before deploying them. Azure Bicep provides conditional expressions, for-loops, and what-if analysis to handle these scenarios elegantly. In this hands-on lab, you will use all three features to build dynamic, environment-aware templates and safely preview infrastructure changes before committing them.
You will start by deploying resources conditionally using the Bicep if expression with a boolean parameter. Then you will create multiple storage accounts dynamically using for loops with integer ranges. Next, you will combine conditions and loops to selectively deploy resources from a configuration array, using ternary expressions for environment-specific SKU selection. Finally, you will use az deployment group what-if to preview changes before deploying, learning to interpret the +Create, -Delete, and ~Modify output symbols that show exactly what will happen.
Objectives
Upon completing this intermediate level lab, you will be able to:
- Deploy Azure resources conditionally using the Bicep
ifexpression and parameter-driven logic - Create multiple resources dynamically using Bicep
forloops with integer ranges and arrays - Combine conditional expressions with loops to selectively deploy resources based on configuration
- Preview infrastructure changes using
az deployment group what-ifbefore committing a deployment - Interpret what-if output symbols (+Create, -Delete, ~Modify) to understand planned changes
- Deploy with
--confirm-with-what-ifto review and approve changes interactively
Who is this lab for?
This lab is designed for:
- Cloud engineers who want to write dynamic, environment-aware Bicep templates that adapt to different configurations
- DevOps practitioners looking to implement safe deployment practices with what-if preview analysis
Verified against your live environment
An automated validation engine inspects your actual resources and configurations as you work. Completion means the task was performed — not multiple choice, real-world proficiency.
More labs like this
Deploy a Full Azure Environment Using Bicep Infrastructure as Code
Write modular Bicep templates to deploy a VNet, App Service, SQL Database, and Key Vault, then deploy the full environment using Azure CLI.
Creating a Web App on Azure App Service using Azure Portal
Learn how to create, configure, and deploy a web application using Azure App Service through the Azure Portal's interface.
Automate Bicep Deployments with GitHub Actions CI/CD Pipeline
Build a GitHub Actions CI/CD pipeline that lints, validates, previews, and deploys Bicep templates to Azure with approval gates.
Related reading
Environment
Every lab includes
- Real environment, pre-credentialed
- Automated checks on every step
- Isolated sandbox, auto cleanup
- AI-recommended next steps
Lab curriculum
- 01
Logging into Azure CLI
- 02
Deploying Resources Conditionally with Bicep If Expressions
1 automated check
- 03
Creating Multiple Storage Accounts Using Bicep For Loops
1 automated check
- 04
Combining Conditions and Loops in a Bicep Template
1 automated check
- 05
Previewing Infrastructure Changes with What-If Analysis
1 automated check
Skills validated
Not the lab you were looking for?
Browse 150+ hands-on labs across AWS, Azure, Kubernetes, Docker, and cloud security.