Applying Conditions to Your Bicep Files to Deploy at Scale

45 minutes
  • 3 Learning Objectives

About this Hands-on Lab

In this lab, we will exercise the ability to deploy identical resources without having to add each resource manually, as well as add conditional logic to decide if resources should be deployed or not. We will do this by adding a loop and a condition based on parameter values.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Add Loop
  • Grab the initialdeploy.bicep file to be edited:
    https://github.com/linuxacademy/content-intro-to-azure-resource-manager/blob/main/lab-applying-conditions-to-your-bicep-files-to-deploy-at-scale/initialdeploy.bicep
  • Add a parameter in the Bicep file for number of storage accounts.
  • Add a loop to the storage account resource to deploy based on the number in the parameter.
Add Condition
  • Add a parameter in the Bicep file to determine if the storage accounts are new or existing.
  • Only allow the following values for the parameter:
    • new
    • existing
  • Add a condition to the storage account resource to only deploy the resource if the parameter value is ‘new’.
Deploy Bicep File
  • Test to see if condition works by using ‘existing’ as parameter value.
  • Test to see if condition works by using ‘new’ as parameter value.
  • Deploy 3 storage accounts.

Additional Resources

You should be familiar with the following to use this hands-on lab:

  • Bicep Files
  • Azure Storage
  • Azure Cloud Shell
  • Azure PowerShell/Azure CLI

Lab Files

 https://github.com/linuxacademy/content-intro-to-azure-resource-manager/tree/main/lab-applying-conditions-to-your-bicep-files-to-deploy-at-scale

Note about lab startup:

When starting up the lab environement, you may see an error such as:

    An error occured when trying to fetch resources. Additional details from the underlying API that might be helpful: Please provide below info when asking for support: timestamp = 2022-02-08T18:43:45.8593786Z, correlationId = 11343c5a-9f20-4ef0-a67d-614bbe889e37. (Code: AccessDenied) Access is denied to the requested resource. The user might not have enough permission. (Code: AccessDenied) Try refreshing the page. Your resources aren't affected by the issue, we're just having trouble showing this view right now. To see a list of resources, select Simplified View.

This is a known error and can be disregarded. It will not prevent you from working in the lab environment.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?