Get started with project bicep

project bicep ... an arm dsl

Chendrayan Venkatesan

3 minute read


Refer to the below links to know more about the project bicep

  1. GitHub

    1. Repository
    2. Docs
    3. Examples
    4. Tutorials
    5. Specifications
  2. YouTube

    1. Intro to Azure’s Project Bicep with Brendan Burns and team
    2. Project Bicep Demo at Ignite 2020 by Mark Russinovich
    3. Project Bicep and ARM Templates November 2020 Update


As a first step, we need to install the bicep tools on our local computer. If you need to deploy the solution using Az DevOps, follow the steps given in the “Deploy Bicep Solution using Azure DevOps” section.

Install Bicep

$installPath = "$env:USERPROFILE\.bicep"
$installDir = New-Item -ItemType Directory -Path $installPath -Force
$installDir.Attributes += 'Hidden'
(New-Object Net.WebClient).DownloadFile("", "$installPath\bicep.exe")
$currentPath = (Get-Item -path "HKCU:\Environment" ).GetValue('Path', '', 'DoNotExpandEnvironmentNames')
if (-not $currentPath.Contains("%USERPROFILE%\.bicep")) { setx PATH ($currentPath + ";%USERPROFILE%\.bicep") }
if (-not $env:path.Contains($installPath)) { $env:path += ";$installPath" }
bicep build main.bicep

Upon the successful installation, try the below-listed commands

Bicep version
Bicep help

Create project scaffolding

┣ 📂scripts
┣ 📂storage_account
┃ ┗ 📜storage_account.bicep
┣ 📜main.bicep

(storage_account.bicep) file

param storage_account_name string = 'stgbicepdev'

resource storage_account 'Microsoft.Storage/storageAccounts@2020-08-01-preview' = {
  name: 'stgbicepdev'
  location: 'eastus2'
  properties: {
    accessTier: 'Hot'
  sku: {
    name: 'Standard_LRS'
    tier: 'Standard'
  kind: 'BlobStorage'

(storage_account.bicep) file

targetScope = 'subscription'

param resource_group_name string = 'rg-bicep-dev'

resource rg 'Microsoft.Resources/resourceGroups@2020-06-01' = {
  name: resource_group_name
  location: 'eastus2'

module storage_account './storage_account/storage_account.bicep' = {
  name: 'storage_account'
  scope: resourceGroup(


Now it’s time for us to start with the first build

PS C:\repos\Project-Bicep\src> build bicep .\main.bicep

If the above command is successful, we should see a main.json file in the ‘SRC’ folder.

Test and Deploy

PS C:\repos\Project-Bicep\src> Test-AzDeployment -Location 'East US 2' -TemplateFile .\main.json -Verbose
PS C:\repos\Project-Bicep\src> New-AzDeployment -Location 'East US 2' -TemplateFile .\main.json -Verbose

How do we show the outputs?

# MODULE (storage_account.bicep)
output storage_account_id string =
# MAIN (main.bicep)
output storage_account_id string = storage_account.outputs.storage_account_id


Deploy project bicep using Azure DevOps

To deploy the bicep solutions using Az DevOps, a minor change is required in the project scaffolding. Below illustrated tree view helps you to get it done.

┗ 📜storage_account.yml

Add a folder “.azure-pipelines,” and underneath it, add a file name “storage_account.yml.”

To install the bicep cli in the Az DevOps pipeline, we use the same PowerShell script file (Refer install bicep section in introduction). It’s nice to place it inside the script folder as shown below



Replace the value of azureResourceManagerConnection and subscriptionId

      - 'main'

  vmImage: 'windows-latest'

  - stage: 'BUILD'
      - job: 
          - task: PowerShell@2
              targetType: filePath
              filePath: '\scripts\BICEP.PS1'
          - task: CopyFiles@2
              SourceFolder: '.\SRC\'
              Contents: '*.json'
              TargetFolder: $(Build.ArtifactStagingDirectory)
          - task: PublishBuildArtifacts@1
              PathtoPublish: $(Build.ArtifactStagingDirectory)
              ArtifactName: 'BICEP'
  - stage: 'RELEASE'
      - job: 
          - task: DownloadBuildArtifacts@0
              buildType: current
              downloadType: single
              artifactName: BICEP
              downloadPath: $(System.ArtifactsDirectory)
          - task: AzureResourceManagerTemplateDeployment@3
              azureResourceManagerConnection: '{SERVICE CONNECTION NAME}'
              deploymentScope: Subscription
              csmFile: '$(System.ArtifactsDirectory)\src\MAIN.json'
              location: 'eastus2'
              deploymentName: 'AZURE.WVD'
              subscriptionId: '{SUBSCRIPTION ID}'
comments powered by Disqus