Tutorial : Developing ARM Templates using Azure Bicep

 In this article, we will learn how to use Azure Bicep for developing ARM templates. The Azure Bicep is an abstraction on top of the ARM JSON syntax that makes the authoring experience of ARM templates easier.

Azure Resource Manager templates (ARM templates) are used to implement infrastructure as code for your Azure solutions. These templates are a JavaScript Object Notation (JSON) file that is used to define the infrastructure and configuration for the project. It uses declarative syntax, for stating your intentions to deploy without having to write the sequence of programming commands to create it.  In the template, you just specify the resources to deploy and the properties for those resources.

Implementation:

Follow the below steps to develop ARM templates using Azure Bicep:

Step 1: There is a VS Code extension for Bicep. Let’s install it.  


Step 2: To make it work completely, we’ll open a terminal. We already have the Azure CLI installed so, we can now do az bicep install. 

Step 3: We’ll create a file called main. bicep. Visual Studio Code will recognize it and give us some tools to work with. For instance, when we start typing, it suggests code snippets for us, like this one for an Azure App Service plan.



Step 4: We’ll continue here with web and this one for an App Service Web App. 



Step 5:The snippets have default names in them, so let’s change this one for the App Service Plan. This doesn’t have to be unique, and we will use it in here so that the web app uses this App Service Plan. 



Step 6: We don’t need tags for the web app, so we’ll delete those. Let’s see some Bicep. We can create a parameter for the name, so a string parameter, and use that here. This is useful for a user to fill in as a web app needs to have a unique name.



Step 7: Bicep has lots of goodies like annotations. This parameter has a minimum length of 1 and a maximum length of 59. We have full IntelliSense. Finally, we’ll make the web app depend on the App Service Plan. This ensures that the App Service Plan gets deployed first and the web app only deploys when the App Service Plan succeeds.



Step 8: With the button on the right, we can open the visualization of the Bicep file. This is very useful when we have resources that depend on each other. The Bicep file can become very complex.



Step 9:  Let’s deploy this. We’ll open a terminal and now we’ll do az deployment group create. This will deploy to a resource group that already exists. We need to fill in a name for the parameter. 

The web app and App Service Plan were deployed successfully.



Azure Bicep is an infrastructure as code language that makes it easy to create ARM templates using IntelliSense, code snippets, and compiler error checking. Go and check it out.

Comments

Popular posts from this blog

Terraform

Different Types of Reports in Scrum - Agile

Scrum Master Interview help - Bootcamp