Bicep language
Microsoft's declarative language for Azure: resources are declared by symbolic name and compiled by the Bicep CLI into a Resource Manager JSON template, so the ARM engine keeps the state and the orchestration.
Overview
Bicep is Microsoft's declarative language for deploying Azure resources, and a transparent abstraction over Resource Manager templates. It exists because the equivalent JSON template is verbose and full of bracketed expressions; Bicep compiles to that same template, so nothing the platform supports is lost.
Code
@description('Region for every resource') // decorator: metadata
param location string = resourceGroup().location
param count int = 2
var name = 'store${uniqueString(resourceGroup().id)}' // interpolation
var ok = count > 1 && location != '' // logical operators
var suffix = count == 2 ? 'pair' : 'many' // conditional
output summary string = '${name}-${suffix}'
output flag bool = ok
var regions = ['eastus', 'westus2']
var sizes = { small: 'Standard_LRS', large: 'Premium_LRS' }
output first string = regions[0] // index accessor
output picked string = sizes.small // property accessor
output both array = concat(regions, ['centralus'])
resource store 'Microsoft.Storage/storageAccounts@2023-05-01' = {
name: name
location: location
sku: { name: sizes.small }
kind: 'StorageV2'
}
resource rg 'Microsoft.Resources/resourceGroups@2025-04-01' existing = {
name: 'shared-rg'
scope: subscription() // a resource group lives at subscription scope
}
module net './net.bicep' = [for region in regions: {
name: 'net-${region}'
params: { region: region }
}]
output endpoints array = [for (region, i) in regions: {
region: region
endpoint: net[i].outputs.endpoint // same bound as the module loop
}]
concat; a resource
or existing resource is the abstraction (reusing name, location and
sizes from the tabs above), and a for loop
over a module is the idiom. net[i] needs no dependsOn: the symbolic
reference is the edge the ARM engine orders on.Distinctive traits
- A resource is named by a symbol, not a string:
storeis an identifier that the compiler maps to a resource id, so property references replace mostdependsOnandreference()calls. - Type safety is compile-time: declared parameters and variables are
checked, while
anyexplicitly disables that checking for one symbol. - Literal and union types narrow a value to a set of constants, so an invalid SKU name fails at build time rather than mid-deployment.
- User-defined types
put a name on a configuration shape, and
decorators
like
@secure()and@allowed()attach validation to that name. - Modules are files or registry artifacts compiled into nested deployments, so reuse needs no separate template service.
existingdeclares a resource you do not own: it is read for its properties and never redeployed, which is how a configuration reaches into another resource group or subscription.
Status
Active and open source under the MIT licence; the compiler ships as the Bicep CLI and as the VS Code extension. Version numbers remain 0.x, and Microsoft's documentation marks experimental features as unsupported.
History
The compiler's first public release is tagged 28 August 2020. Microsoft
introduced Project Bicep
as a domain-specific language for ARM templates, and the repository ships the
bicep decompile
command that turns an existing ARM JSON template back into Bicep. The compiler
is written in C#; the VS Code extension is TypeScript.
Sources & references
- Official sitelearn.microsoft.com
- Bicep file structure and syntaxlearn.microsoft.com
- Data types in Biceplearn.microsoft.com
- Iterative loops in Biceplearn.microsoft.com
- Bicep moduleslearn.microsoft.com
- Reference existing resource in Biceplearn.microsoft.com
- Azure/bicep — the Bicep compiler repository (MIT)github.com
- Bicep v0.1.1-alpha, the first public release (28 August 2020)github.com