Bicep File Structure
You'll learn the essential building blocks that make up every Bicep file and how they work together to define Azure infrastructure.
The Four Pillars of a Bicep File
Think of a Bicep file like a recipe: you need ingredients (parameters), prep work (variables), the actual cooking steps (resources), and what you're serving (outputs). Every Bicep file organizes infrastructure code using these four optional-but-common sections.
Parameters
Parameters are inputs to your template—values you provide at deployment time. They make your Bicep files reusable across environments.
param location string = 'eastus'
param storageAccountName string
Variables
Variables store calculated or repeated values within your template. They simplify your code by avoiding repetition.
var uniqueSuffix = uniqueString(resourceGroup().id)
var fullStorageName = '${storageAccountName}${uniqueSuffix}'
Resources
Resources are the actual Azure infrastructure you're deploying—storage accounts, VMs, databases, etc. This is the heart of your Bicep file.
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-06-01' = {
name: fullStorageName
location: location
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
}
Outputs
Outputs return values after deployment completes—like connection strings or resource IDs that other templates or scripts might need.
output storageEndpoint string = storageAccount.properties.primaryEndpoints.blob
How They Work Together
Parameters flow into variables, variables simplify resource declarations, and resources produce outputs. Unlike ARM templates, Bicep doesn't require you to declare these sections explicitly—just write them in any order, and Bicep figures out the dependencies.
Key Takeaway: A Bicep file structures infrastructure as code using four building blocks—parameters for inputs, variables for intermediate values, resources for actual infrastructure, and outputs for deployment results.