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.
- Grab the
- 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.