0
0
Azurecloud~10 mins

Bicep syntax and modules in Azure - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Bicep syntax and modules
Start Bicep file
Define parameters
Define variables
Use modules to call other Bicep files
Define resources
Output values
Deploy Bicep template
This flow shows how a Bicep file is structured: starting with parameters and variables, then calling modules, defining resources, and finally outputs before deployment.
Execution Sample
Azure
param location string = 'eastus'
module storageModule './storage.bicep' = {
  name: 'storageDeploy'
  params: {
    location: location
  }
}
output storageId string = storageModule.outputs.storageAccountId
This Bicep code defines a location parameter, calls a storage module passing the location, and outputs the storage account ID from the module.
Process Table
StepActionEvaluationResult
1Read parameter 'location'Default 'eastus'location = 'eastus'
2Call module './storage.bicep'Pass param location='eastus'Module deployment started
3Module './storage.bicep' deploys storage accountUses location='eastus'Storage account created
4Module outputs 'storageAccountId'Captured as storageModule.outputs.storageAccountIdValue available
5Define output 'storageId'Assign storageModule.outputs.storageAccountIdOutput ready
6Bicep deployment completesAll resources and outputs definedDeployment successful
💡 Deployment ends after all resources and outputs are processed successfully.
Status Tracker
VariableStartAfter Module CallFinal
location'eastus''eastus''eastus'
storageModule.outputs.storageAccountIdundefinedassigned after module deployassigned after module deploy
storageIdundefinedundefinedstorageModule.outputs.storageAccountId
Key Moments - 2 Insights
Why do we pass parameters to modules instead of hardcoding values?
Passing parameters allows modules to be reusable and flexible. As shown in step 2 of the execution_table, the location parameter is passed to the module, so it can deploy resources in different locations without changing the module code.
How do outputs from modules become available in the main Bicep file?
Outputs from modules are accessed via the module's outputs property. In step 4, the storageAccountId output from the module is captured and then assigned to the main output in step 5.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the value of 'location' after step 1?
A'westus'
B'eastus'
Cundefined
D'centralus'
💡 Hint
Check the 'Evaluation' column in step 1 where 'location' is set to 'eastus'.
At which step does the module './storage.bicep' complete creating the storage account?
AStep 3
BStep 2
CStep 4
DStep 5
💡 Hint
Look at the 'Action' and 'Result' columns in step 3 describing module deployment.
If the parameter 'location' was changed to 'westus', which step's evaluation would change?
AStep 5 only
BStep 1 only
CStep 2 and Step 3
DNo steps would change
💡 Hint
Refer to steps 2 and 3 where the location parameter is passed and used in the module deployment.
Concept Snapshot
Bicep files start with parameters and variables.
Modules are called with 'module' keyword and accept parameters.
Modules deploy resources and return outputs.
Outputs from modules are accessed via 'moduleName.outputs'.
This structure enables reusable, clean infrastructure code.
Full Transcript
This lesson shows how Bicep syntax organizes infrastructure as code. First, parameters like 'location' are defined with default values. Then, modules are called using the 'module' keyword, passing parameters to them. The module deploys resources, such as a storage account, using the passed parameters. After deployment, the module outputs values like the storage account ID. These outputs are accessed in the main Bicep file through the module's outputs property and can be assigned to outputs for use after deployment. This approach helps keep code modular and reusable. The execution table traces each step from reading parameters, calling modules, deploying resources, capturing outputs, and completing deployment. Variables like 'location' and module outputs change state as deployment progresses. Key moments clarify why parameters are passed to modules and how outputs are accessed. The quiz tests understanding of variable values, deployment steps, and parameter effects. The snapshot summarizes the core syntax and behavior of Bicep modules.