Bird
Raised Fist0
Azurecloud~20 mins

Bicep as ARM simplification in Azure - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

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
Challenge - 5 Problems
🎖️
Bicep Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Bicep Resource Declaration
Which of the following Bicep resource declarations correctly creates an Azure Storage Account with the name 'mystorageacct' in the 'eastus' region?
A
resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = {
  name: 'mystorageacct'
  location: 'eastus'
  sku: {
    name: 'Standard_LRS'
  }
}
B
resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = {
  name: 'mystorageacct'
  location: 'westus'
  kind: 'StorageV2'
  sku: {
    name: 'Standard_LRS'
  }
}
C
resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = {
  name: 'mystorageacct'
  location: 'eastus'
  kind: 'StorageV2'
  sku: {
    name: 'Standard_LRS'
  }
}
D
resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = {
  name: 'mystorageacct'
  location: 'eastus'
  kind: 'BlobStorage'
  sku: {
    name: 'Standard_LRS'
  }
}
Attempts:
2 left
💡 Hint
Remember that the location must be 'eastus' and the kind should be 'StorageV2' for a general-purpose storage account.
Configuration
intermediate
2:00remaining
Bicep Module Parameter Passing
Given a Bicep module that requires a parameter 'vmName' of type string, which option correctly passes the value 'myVM01' to this module?
Azure
module vmModule './vm.bicep' = {
  name: 'deployVM'
  params: {
    vmName: 'myVM01'
  }
}
A
module vmModule './vm.bicep' = {
  name: 'deployVM'
  params: {
    vmName: 'myVM01'
  }
}
B
module vmModule './vm.bicep' = {
  name: 'deployVM'
  vmName: 'myVM01'
}
C
module vmModule './vm.bicep' = {
  name: 'deployVM'
  parameters: {
    vmName: 'myVM01'
  }
}
D
module vmModule './vm.bicep' = {
  name: 'deployVM'
  args: {
    vmName: 'myVM01'
  }
}
Attempts:
2 left
💡 Hint
Check the correct keyword for passing parameters to a module in Bicep.
Architecture
advanced
2:00remaining
Bicep Deployment Scope Selection
You want to deploy a Bicep template that creates a resource group and resources inside it in a single deployment. Which deployment scope should you use in your Bicep file to achieve this?
AUse 'targetScope = 'managementGroup'' to deploy the resource group and nested resources.
BUse 'targetScope = 'subscription'' to deploy the resource group and nested resources.
CUse 'targetScope = 'resourceGroup'' to deploy the resource group and nested resources.
DUse 'targetScope = 'tenant'' to deploy the resource group and nested resources.
Attempts:
2 left
💡 Hint
Creating a resource group requires subscription-level deployment scope.
security
advanced
2:00remaining
Secure Parameter Handling in Bicep
Which Bicep parameter declaration ensures that a sensitive value like an admin password is not logged or exposed during deployment?
Aparam adminPassword securestring
Bparam adminPassword string = 'P@ssw0rd!'
Cparam adminPassword string { secure: true }
Dparam adminPassword string
Attempts:
2 left
💡 Hint
Bicep has a special type for sensitive parameters.
service_behavior
expert
2:00remaining
Bicep Output Behavior After Deployment
After deploying a Bicep template that outputs a storage account's primary endpoint URL, what will be the value of the output if the deployment fails halfway and the storage account resource was not created?
Azure
output storageEndpoint string = storageAccount.properties.primaryEndpoints.blob
AThe output will be null because the resource was not created.
BThe output will be an empty string.
CThe output will contain the endpoint URL from the previous deployment.
DThe deployment will fail and no outputs will be returned.
Attempts:
2 left
💡 Hint
Consider what happens to outputs when deployment fails.

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

  1. 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.
  2. Step 2: Compare with other options

    Options A, B, and C describe other Azure tools or features, not Bicep's main purpose.
  3. Final Answer:

    To simplify writing and managing Azure resource templates -> Option D
  4. 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

  1. 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.
  2. 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.
  3. Final Answer:

    param location string -> Option A
  4. Quick Check:

    Parameter declaration = param name type [OK]
Hint: Use 'param' keyword for parameters in Bicep [OK]
Common Mistakes:
  • Using 'var' instead of 'param' for parameters
  • Confusing resource declaration with parameter
  • Incorrect assignment syntax for parameters
3. Given this Bicep snippet:
param storageAccountName string = 'mystorage'
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-04-01' = {
  name: storageAccountName
  location: 'eastus'
  kind: 'StorageV2'
  sku: {
    name: 'Standard_LRS'
  }
}

What will be the name of the deployed storage account?
medium
A. mystorage
B. storageAccountName
C. Standard_LRS
D. eastus

Solution

  1. Step 1: Identify the parameter value

    The parameter storageAccountName is set to the string 'mystorage'.
  2. Step 2: Check resource name assignment

    The resource's name property uses the parameter storageAccountName, so the deployed storage account will be named 'mystorage'.
  3. Final Answer:

    mystorage -> Option A
  4. Quick Check:

    Resource name = parameter value 'mystorage' [OK]
Hint: Resource name uses parameter value directly [OK]
Common Mistakes:
  • Confusing parameter name with its value
  • Choosing SKU or location as name
  • Assuming default resource name
4. You wrote this Bicep code:
param location string
var location = 'westus'
resource vm 'Microsoft.Compute/virtualMachines@2022-03-01' = {
  name: 'myVM'
  location: location
}

What is the error in this code?
medium
A. Missing SKU property in the resource
B. Resource name must be a parameter, not a string
C. Variable and parameter have the same name causing conflict
D. Location property cannot be a variable

Solution

  1. Step 1: Identify naming conflict

    Both a parameter and a variable are named location, which causes a conflict in Bicep because names must be unique in the same scope.
  2. Step 2: Check other options

    Resource name can be a string literal; SKU is not mandatory for all resources; location can be a variable if no conflict exists.
  3. Final Answer:

    Variable and parameter have the same name causing conflict -> Option C
  4. Quick Check:

    Duplicate names cause errors in Bicep [OK]
Hint: Avoid using same name for param and var [OK]
Common Mistakes:
  • Thinking resource name must be a parameter
  • Assuming SKU is always required
  • Believing location cannot be variable
5. You want to deploy two storage accounts in different locations using Bicep. Which approach correctly uses a loop to create these resources?
hard
A. param locations string = 'eastus,westus' resource storageAccounts 'Microsoft.Storage/storageAccounts@2021-04-01' = { name: 'storage' location: locations kind: 'StorageV2' sku: { name: 'Standard_LRS' } }
B. 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' } }]
C. var locations = ['eastus', 'westus'] resource storageAccounts 'Microsoft.Storage/storageAccounts@2021-04-01' = { name: 'storage' location: locations kind: 'StorageV2' sku: { name: 'Standard_LRS' } }
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

  1. Step 1: Understand Bicep loop syntax

    Bicep uses array loops with the syntax [for item in array: { ... }] to create multiple resources.
  2. 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.
  3. 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
  4. 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