Automating Azure Infrastructure with Bicep: A Hands-On IaC Lab Using VS Code

Deploying VNets, VMs, IAM, Policies, Monitoring, and Governance using Infrastructure as Code.

Manual infrastructure deployment does not scale in modern cloud environments. Infrastructure as Code (IaC) enables teams to deploy, manage, and govern Azure resources consistently, securely, and repeatedly.

In this hands-on lab, I automated a full Azure infrastructure deployment using Bicep, ARM templates, and Visual Studio Code, replicating how enterprises provision cloud environments at scale.

This walkthrough covers networking, compute, security, governance, monitoring, and identity, all deployed via code.

🎥 Video Walkthrough

Lab Objectives

By the end of this lab, you will be able to:

  • Set up a local Azure IaC development environment

  • Deploy Azure infrastructure using Bicep

  • Implement identity and access control with Microsoft Entra ID

  • Enforce governance with Azure Policy

  • Apply consistent tagging automatically

  • Validate deployments using Azure Portal and CLI

Lab Prerequisites

  • Azure subscription

  • Azure CLI installed

  • Visual Studio Code

  • Bicep extension

  • Azure Account extension

  • ARM Template Viewer

Part 1: Set Up the Development Environment

  1. Install Visual Studio Code

  2. Install required extensions:

    • Azure Account

    • Bicep

    • ARM Template Viewer

  3. Authenticate to Azure:

 az login 

Part 2: Create the Resource Group

Define a resource group to logically contain all resources.


az group create \
--name rg-iac-lab \
--location eastus

Part 3: Write and Deploy Bicep Templates

Bicep templates were created for:

  • Virtual Networks & Subnets
  • Network Security Groups
  • Network Interfaces
  • Windows & Linux Virtual Machines
  • Storage Accounts
  • Azure Monitor
  • Resource Tagging (automatic)

Deploy using:

 az deployment group create \
  --resource-group rg-iac-lab \
  --template-file main.bicep

Part 4: Identity & Access Management (IAM)

Using Microsoft Entra ID:

  • Managed users and groups
  • Enabled Privileged Identity Management (PIM)
  • Assigned Contributor role via Just-In-Time (JIT) access
  • Verified role activation in the Azure Portal

Part 5: Security Governance with Azure Policy

Validation steps:

  • Checked deployments in Azure Portal

  • Verified resource tags

  • Confirmed JIT role activation

  • Reviewed policy compliance status

✅ All resources deployed successfully
✅ Governance enforced
✅ Access controlled
✅ Infrastructure fully automated

Why Bicep?

Bicep was chosen because:

  • Cleaner syntax than raw ARM JSON

  • Faster development

  • Native Azure support

  • Excellent VS Code integration (autocomplete, validation)

Key Takeaway

Infrastructure as Code is no longer optional in cloud engineering.

Using Bicep allows teams to:

  • Reduce configuration drift

  • Improve security and governance

  • Scale environments confidently

  • Deploy infrastructure the same way, every time

This lab demonstrates real-world Azure automation, not just theory.


Discover more from Humble Cloud Tech

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners. View more
Cookies settings
Accept
Decline
Privacy & Cookie policy
Privacy & Cookies policy
Cookie name Active

Who we are

Suggested text: Our website address is: https://humbletech.cloud.

Comments

Suggested text: When visitors leave comments on the site we collect the data shown in the comments form, and also the visitor’s IP address and browser user agent string to help spam detection. An anonymised string created from your email address (also called a hash) may be provided to the Gravatar service to see if you are using it. The Gravatar service Privacy Policy is available here: https://automattic.com/privacy/. After approval of your comment, your profile picture is visible to the public in the context of your comment.

Media

Suggested text: If you upload images to the website, you should avoid uploading images with embedded location data (EXIF GPS) included. Visitors to the website can download and extract any location data from images on the website.

Cookies

Suggested text: If you leave a comment on our site you may opt in to saving your name, email address and website in cookies. These are for your convenience so that you do not have to fill in your details again when you leave another comment. These cookies will last for one year. If you visit our login page, we will set a temporary cookie to determine if your browser accepts cookies. This cookie contains no personal data and is discarded when you close your browser. When you log in, we will also set up several cookies to save your login information and your screen display choices. Login cookies last for two days, and screen options cookies last for a year. If you select "Remember Me", your login will persist for two weeks. If you log out of your account, the login cookies will be removed. If you edit or publish an article, an additional cookie will be saved in your browser. This cookie includes no personal data and simply indicates the post ID of the article you just edited. It expires after 1 day.

Embedded content from other websites

Suggested text: Articles on this site may include embedded content (e.g. videos, images, articles, etc.). Embedded content from other websites behaves in the exact same way as if the visitor has visited the other website. These websites may collect data about you, use cookies, embed additional third-party tracking, and monitor your interaction with that embedded content, including tracking your interaction with the embedded content if you have an account and are logged in to that website.

Who we share your data with

Suggested text: If you request a password reset, your IP address will be included in the reset email.

How long we retain your data

Suggested text: If you leave a comment, the comment and its metadata are retained indefinitely. This is so we can recognise and approve any follow-up comments automatically instead of holding them in a moderation queue. For users that register on our website (if any), we also store the personal information they provide in their user profile. All users can see, edit, or delete their personal information at any time (except they cannot change their username). Website administrators can also see and edit that information.

What rights you have over your data

Suggested text: If you have an account on this site, or have left comments, you can request to receive an exported file of the personal data we hold about you, including any data you have provided to us. You can also request that we erase any personal data we hold about you. This does not include any data we are obliged to keep for administrative, legal, or security purposes.

Where your data is sent

Suggested text: Visitor comments may be checked through an automated spam detection service.
Save settings
Scroll to Top