All languages

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
Values and operators fill declarations; arrays and objects are consumed by accessors and 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: store is an identifier that the compiler maps to a resource id, so property references replace most dependsOn and reference() calls.
  • Type safety is compile-time: declared parameters and variables are checked, while any explicitly 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.
  • existing declares 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