Read on:

Microsoft Azure for Beginners: Understanding Azure Terminologies – Part 1
Microsoft Azure for Beginners: How to Create an Azure Virtual Machine – Part 2
Microsoft Azure for Beginners: What is Azure Governance – Part 3
Microsoft Azure for Beginners: What is Azure PaaS – Part 4
Microsoft Azure for Beginners: Cloud Adoption Framework – Part 5

In this article, we will create and deploy our first BICEP template. Let’s get started!

Protect Your Data with BDRSuite

Cost-Effective Backup Solution for VMs, Servers, Endpoints, Cloud VMs & SaaS applications. Supports On-Premise, Remote, Hybrid and Cloud Backup, including Disaster Recovery, Ransomware Defense & more!

What do we need?

I am using my Windows 11 laptop with Visual Studio Code in this example. In addition, I have access to an Azure account, and I have created a resource group MyResourceGroup there. We are going to use this resource group to deploy resources.

Uhhhh … Azure Bicep, what was that again?

Azure Bicep is a syntax-based language that allows you to easily deploy Azure resources repeatedly and in a consistent manner. Bicep is ideal for use as Infrastructure as Code. It provides full support for all resource types and API versions, the syntax is easy, quick to understand and production worthy. It is also fully supported by Microsoft. In addition, it can be built modularly and there is no cost involved. In addition, Azure Bicep is completely open source!

Download Banner

But let’s get started quickly!

Configuration of VSCode

Assuming Visual Studio Code is already installed, open Visual Studio Code and go to extensions. Install the Bicep module.

BICEP

Now that this module is installed in Visual Studio, shortcuts will be offered automatically when opening or creating .bicep files. Let me explain this. Let’s create a .bicep file, example storage.bicep

If you then use a Bicep command, for example resource (this is used to create Azure resources) you will see that Visual Studio Code automatically adds the possible commands :

BICEP

Visual Studio Code makes it very easy for us to use code in the right way and with the right formatting. But Visual Studio Code offers (an awful lot) more! We can also use snippets. Snippets are complete pieces of Bicep code that you can use and possibly modify and use. In this example, we’re going to roll-out a storage account. See what happens when you type res-stor (you don’t have to fill in the whole command, Visual Studio Code completes it automatically)

BICEP

You can see that VSC automatically suggests a piece of code. Let’s use this one.

BICEP

We now have a piece of sample code where we can customize our specific parameters. We still want to modify the name and location. Let’s do this.

BICEP

For demo purposes, we will not use parameter files for the time being. This is because we want to capture all unique values in the template and in a parameter file. But we will cover this at a later moment.

Ok, let’s deploy the template!

BICEP

Open the storage file we just created, and the right mouse button opens the options menu. Choose Deploy Bicep File.

BICEP

Provide a name for deployment

BICEP

The Resource Group in which we want to deploy

BICEP

And a possible parameter file (in this example we are not using it yet)

After a few seconds you will see something similar :

BICEP

Note Deployment succeeded

As you can see next in Azure, the deployment succeeded :

BICEP

BICEP

Now let’s use a parameter for the location.

Azure Bicep

Visual Studio Code automatically “sees” when parameters can be used and helps with this as well. At westeurope you see an orange line, if you click on this you get the tip to create a parameter and the option to set it automatically as well.

Azure Bicep

Once we have done this you will see that part of the code is automatically modified and you use a parameter :

Azure Bicep

You can then deploy this code in exactly the same way. In another article, we’ll look at parameter files and how to easily deploy them, among other things.

Voila! You’ve created and successfully deployed your 1st Bicep template. In subsequent articles, we will look at what other features Azure Bicep offers.

Follow our Twitter and Facebook feeds for new releases, updates, insightful posts and more.

5/5 - (1 vote)