Microsoft has released "Bicep," a domain-specific language (DSL) that uses declarative syntax to deploy Azure resources. Find out what it is and how to start using it in this article!
If you want to set up an Azure Cloud Platform that is (re)deployable and can be moved automatically to higher environments, you need to automate it with scripts and deployment pipelines.
We usually configure our Azure resources with Azure Resource Manager templates (ARM templates), in JSON format, which is readable, but the learning curve to assemble one is quite long and maintaining it can be quite difficult to keep the right structure (the right brackets and spaces in the right place). Also, the mandatory attributes of a resource are not always clear, you often have to look up the JSON functions in the documentation and manually specify the dependencies per resource.
Microsoft has launched an alternative: Bicep. This article gives an overview of it and how to start using this new feature.
What is 'BICEP'?
Microsoft has released "Bicep," a domain-specific language (DSL) that uses declarative syntax to deploy Azure resources. In a Bicep file, you define the infrastructure you want to deploy to Azure, then use that file throughout the development lifecycle to deploy your infrastructure repeatedly. Your resources are deployed consistently.
How to start using Azure Bicep?
Step 1: Preparing to create and use Bicep files
You can use Bicep scripts in AzureCLI or Powershell, but to work with Bicep files, you must install the Bicep :
The simplest is Azure CLI, which you can install via :
- az bicep install (for a first installation)
- az bicep upgrade (for the latest version)
- az bicep version (to confirm the installation)
Azure Powershell (Azure PS version 5.6.0 or later!) :
- for PS, you must perform a manual installation which depends on the operating system you are working on (MacOS, Linux or Windows) in Consult the Microsoft support page to know the appropriate statements for the operating system you are using.
In addition, you can also install the VS Code extension to have code intelligence and validation:
VS Code ==> Extensions ==> BICEP
Step 2: Creating the .bicep file
As mentioned above, you can create your Bicep :
- Manually, directly in Azure Devops ;
- through the VS Code ;
- by decompiling an existing ARM model in Bicep format.
You already have an existing ARM model? Bicep offers migration options.
In the first part of the BICEP file, specify the parameters and variables that you will use to dynamically propagate the resources.
In the second part, specify the resources you will deploy and their properties.
In this example, we show you how to deploy a KeyVault using a Bicep file. This can of course be translated into any other Azure resource type.
In all cases (for all the different types of resources), you will need a resource name, a location and the tenant where you want to deploy it. You can optionally define the Tags you want to add to it.
In this case, for KeyVault, we also define access policies at the level of certificates, keys, etc.
Step 3: Deploying the Bicep file
Bicep offers several options for deploying our file to Azure. The fastest way is through PowerShell or Azure CLI. Other options also exist, using the Bicep Tasks extension for Azure pipelines or Bicep Github Action.
Azure CLI example to deploy our KeyVault:
Successful deployment pipeline:
And the Azure KeyVault has been successfully created with access policies defined (accessPolicies) :
Bicep provides concise syntax, reliable type consistency and support for code reuse. Bicep provides the best authoring experience for yourinfrastructure solutionsas code in Azure. Bicep is a good complement to existing ARM templates, as it has additional benefits that can save you a lot of time and frustration.
Want to know more?
Contact us for more information!