Azure Bicep

Bicep is a ‘Domain Specific Language (DSL) for deploying Azure resources declaratively’. Ok so why do we need yet another way to deploy stuff in Azure? That’s a good question!

There is a huge variety of options to deploy resources in Azure. You can use:

  • The Azure portal
  • ARM template
  • Azure CLI and Azure PowerShell
  • Terraform

The first great advantage of Bicep is the syntax. Comparing with JSON, Bicep files are more concise and easier to read for humans. The second advantage is that Bicep immediately supports all preview and GA versions for Azure services.

I will not explain in detail what is Azure Bicep (Brandon Lee wrote a great article comparing Bicep vs Terraform), Bicep was well explained in this article.

Just remember that if you want to deploy resources in Multi-Cloud, Bicep is not the right tool for you, other cloud providers don’t support Bicep templates.

In this article, I will demonstrate how easy it is to use Azure Bicep to deploy a basic resource in your Azure subscription. You will never use JSON again your entire life!

Getting started

First, I advise you to install VS Code to write your Azure Bicep code. You can install the following extension to validate your code.

Bicep extension provides intellisense for the core language, so you just need to press the space bar (or CTRL + SPACE), then VS Code will list the available options or resource types.

Install Bicep

Ok you just installed VS Code + Bicep extension. Don’t forget to install the Az PowerShell module.

Az PowerShell module

Confirm that bicep extension is loaded

Confirm that bicep extension is loaded

Ok we will connect to our Azure subscription using the ‘Connect-AzAccount’ cmdlet


Now, we can create our first Bicep file (your file must be named using the *.bicep extension)

Get Started

Below is the code that we will use to deploy a storage account.

Below is the code that we will use to deploy a storage account

First, you must tell to Bicep that you want to define a new resource

Resource myStorAccount ‘Microsoft.Storage/’

myStorAccount is just a friendly name inside your code. It will never appear in the Azure console.


Microsoft.Storage/storageAccounts@2021-09-01 is the resource type and API version of the storageAccounts that Bicep will use when it creates the resource.


Be careful, Bicep is strict about where you put line breaks. Just press CTRL + SPACE to create the squelette (e.g required-properties)

Press CTRL + SPACE to create the squelette

Repeat the same steps by pressing CTRL + SPACE for each property. As you can see, VS Code helps you to structure your Bicep code.

VS Code helps you to structure your Bicep code

You can also use parameters. Resource Manager resolves parameter values before starting the deployment operations. Wherever the parameter is used, Resource Manager replaces it with the resolved value. In my case, I use a parameter to replace the location value and to be sure that all the resources will use the same location value.

param loc string = resourceGroup().location

When you deploy your Azure Bicep file, most of time it is deployed in a resource group, so we use the RG location value.

RG location value

Now we will deploy our Bicep code using the following command:

New-AzResourceGrouDeployment -ResourceGroupName <your_RG> -TemplateFile <Bicep_File>

Deploy Bicep code

In the Azure portal, we can confirm the deployment

Azure portal

Just to really understand the power of Bicep instead of JSON complexity, below is the JSON code to create our storage account. Comparing the Bicep code, it saves time and efforts!

JSON code to create our storage account

The storage account is created in the resource group.

Storage account

Now if you want to remove the storage account, create an empty Bicep file

Remove the storage account

And run the following command:

New-AzResourceGrouDeployment -ResourceGroupName <your_RG> -TemplateFile <Bicep_File> -Mode Complete -Force -Verbose

Run the following command

Be very careful! In the « complete » mode, Resource Manager deletes resources that exist in the resource group but aren’t specified in the template. The file ‘clean.bicep’ is empty, so ARM will delete all resources in the RG.

Resource Manager

Another value is ‘Incremental’. In incremental mode, Resource Manager leaves unchanged resources that exist in the resource group but aren’t specified in the template. Resources in the template are added to the resource group.

Below is a simple but very good example from the Microsoft documentation:

Example from the Microsoft documentation

StarWind Backup Appliance (BA) is an industry-first all-NVMe backup appliance that provides unprecedented levels of backup and recovery speed. It comes as a tiny, pre-configured, ready-to-backup solution that eliminates the backup server storage bottleneck and fits even the strictest RTPO. Consisting of the best commodity hardware, your chosen hypervisor, and a StarWind SDS engine backed by 24/7/365 ProActive Support, StarWind BA ushers in a new age of a future-proof, eco-friendly, transparent, and reasonably priced backup infrastructure. Explore Backup Appliance from StarWind StarWind Backup Appliance Datasheet
Back to blog