Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Bicep as ARM simplification
📖 Scenario: You are working as a cloud engineer setting up infrastructure on Microsoft Azure. You want to create a simple storage account using Bicep, which is a simpler way to write Azure Resource Manager (ARM) templates.This project will guide you step-by-step to create a Bicep file that defines a storage account with basic configuration.
🎯 Goal: Build a Bicep file that defines an Azure Storage Account resource with a specified name, location, and SKU. You will start by defining the resource group location, then add configuration variables, define the storage account resource, and finally add tags to the resource.
📋 What You'll Learn
Create a variable for the resource group location
Add a variable for the storage account SKU
Define a storage account resource with the given name, location, and SKU
Add tags to the storage account resource
💡 Why This Matters
🌍 Real World
Cloud engineers use Bicep to write infrastructure as code for Azure resources more easily and readably than raw ARM JSON templates.
💼 Career
Knowing Bicep helps you automate Azure deployments, improve infrastructure consistency, and collaborate better with teams using modern cloud practices.
Progress0 / 4 steps
1
Define the resource group location variable
Create a variable called location and set it to the string 'eastus' in your Bicep file.
Azure
Hint
Use the var keyword to create a variable in Bicep.
2
Add a variable for the storage account SKU
Add a variable called storageSku and set it to the string 'Standard_LRS' in your Bicep file below the location variable.
Azure
Hint
Define another variable using var for the SKU.
3
Define the storage account resource
Define a resource called storageAccount of type 'Microsoft.Storage/storageAccounts@2022-09-01' with the name 'mystorageacct123'. Use the location variable for its location and set its SKU name to the storageSku variable. Use the kind property with value 'StorageV2'.
Azure
Hint
Use the resource keyword to define the storage account with the correct properties.
4
Add tags to the storage account resource
Add a tags property to the storageAccount resource with two tags: environment set to 'dev' and project set to 'bicep-demo'.
Azure
Hint
Add the tags property inside the resource block with the required key-value pairs.
Practice
(1/5)
1. What is the main purpose of Bicep in Azure infrastructure management?
easy
A. To monitor Azure resources in real-time
B. To replace Azure CLI commands
C. To create virtual machines automatically
D. To simplify writing and managing Azure resource templates
Solution
Step 1: Understand Bicep's role
Bicep is designed to simplify the process of writing infrastructure as code for Azure by providing a cleaner syntax than raw ARM templates.
Step 2: Compare with other options
Options A, B, and C describe other Azure tools or features, not Bicep's main purpose.
Final Answer:
To simplify writing and managing Azure resource templates -> Option D
Quick Check:
Bicep simplifies Azure templates = D [OK]
Hint: Bicep makes Azure templates easier to write and read [OK]
Common Mistakes:
Confusing Bicep with Azure CLI
Thinking Bicep creates resources automatically
Assuming Bicep monitors resources
2. Which of the following is the correct way to declare a string parameter named location in a Bicep file?
easy
A. param location string
B. parameter location = 'string'
C. var location string
D. resource location string
Solution
Step 1: Recall Bicep parameter syntax
In Bicep, parameters are declared using the keyword param followed by the name and type, e.g., param location string.
Step 2: Eliminate incorrect options
parameter location = 'string' uses incorrect syntax; var location string uses var which is for variables, not parameters; resource location string uses resource which is for resources.
Final Answer:
param location string -> Option A
Quick Check:
Parameter declaration = param name type [OK]
Hint: Use 'param' keyword for parameters in Bicep [OK]
D. param locations array = ['eastus', 'westus']
resource storageAccounts 'Microsoft.Storage/storageAccounts@2021-04-01' = for loc in locations {
name: 'storage'
location: loc
kind: 'StorageV2'
sku: { name: 'Standard_LRS' }
}
Solution
Step 1: Understand Bicep loop syntax
Bicep uses array loops with the syntax [for item in array: { ... }] to create multiple resources.
Step 2: Analyze each option
var locations = ['eastus', 'westus']
resource storageAccounts 'Microsoft.Storage/storageAccounts@2021-04-01' = [for loc in locations: {
name: 'storage${loc}'
location: loc
kind: 'StorageV2'
sku: { name: 'Standard_LRS' }
}] correctly uses a variable array and a loop to create multiple storage accounts with unique names and locations. Options B and C misuse the location property by assigning an array directly. param locations array = ['eastus', 'westus']
resource storageAccounts 'Microsoft.Storage/storageAccounts@2021-04-01' = for loc in locations {
name: 'storage'
location: loc
kind: 'StorageV2'
sku: { name: 'Standard_LRS' }
} has incorrect loop syntax missing square brackets.
Final Answer:
var locations = ['eastus', 'westus']
resource storageAccounts 'Microsoft.Storage/storageAccounts@2021-04-01' = [for loc in locations: {
name: 'storage${loc}'
location: loc
kind: 'StorageV2'
sku: { name: 'Standard_LRS' }
}] -> Option B
Quick Check:
Bicep loops use [for item in array: {...}] [OK]
Hint: Use [for item in array: {...}] for resource loops [OK]
Common Mistakes:
Assigning array directly to location property
Incorrect loop syntax without brackets
Using string instead of array for multiple locations