Deploying a Scalable Azure Environment with Bicep: VMs, NSGs, Subnets & Load Balancer (Step-by-Step Lab)

A hands-on IaC walkthrough using VS Code and Bicep to build a secure, highly available Azure environment.

Scalable cloud environments are not built by chance. They are designed with network isolation, availability, security, and automation in mind.

This hands-on lab demonstrates how a production-ready Azure environment can be deployed using Visual Studio Code and Bicep. Instead of relying solely on portal clicks, infrastructure is defined as code to ensure repeatability, consistency, and governance.

The walkthrough focuses on deploying virtual machines, securing them with NSGs, distributing traffic with a load balancer, and applying tagging for visibility and cost management.

🎥 Video Walkthrough

 

Lab Objectives

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

  • Deploy Linux virtual machines using Bicep

  • Design a clean Azure VNet with multiple subnets

  • Secure workloads using Network Security Groups

  • Implement high availability with an Availability Set

  • Configure an Azure Load Balancer for traffic distribution

  • Apply consistent tagging for governance and cost control

Lab Architecture Overview

The environment includes:

  • One resource group

  • One virtual network

  • Two subnets (one per VM)

  • Two Linux virtual machines (Standard_B2s)

  • Network Security Groups per subnet

  • Availability Set

  • Azure Load Balancer (Layer 4)

Resource Group and Network Design

A dedicated resource group was created to logically group all networking and compute resources.

The virtual network was designed with non-overlapping address spaces, ensuring clean segmentation and future scalability.

Subnet separation allows security policies and traffic controls to be applied independently per workload.

Deploy Linux Virtual Machines with Bicep

Two Linux virtual machines were deployed using the Standard_B2s SKU.

Each VM was:

  • Placed in its own subnet

  • Associated with a dedicated NIC

  • Protected by subnet-level NSGs

Automation through Bicep ensured consistency across both deployments.

Network Security Groups (NSGs)

Security was enforced at the subnet level using Network Security Groups.

Inbound rules were configured to allow:

  • SSH (22): for administration

  • HTTP (80): for testing load-balanced traffic

This approach keeps security centralized and easy to audit.

Availability Set Configuration

An Availability Set was used to distribute both virtual machines across:

  • Fault domains

  • Update domains

This configuration reduces downtime during maintenance or unexpected infrastructure failures.

Azure Load Balancer Setup

What Is Azure Load Balancer?

Azure Load Balancer is a Layer 4 (TCP/UDP) service that distributes traffic across backend resources to improve availability and performance.

Configuration Steps

  • Public IPs were disassociated from individual VMs

  • A frontend IP configuration was created

  • Both VMs were added to the backend pool

  • A health probe was defined to monitor availability

  • Inbound NAT rules were configured for SSH access using custom ports

Traffic is now evenly distributed while still allowing secure administrative access.

Tagging Strategy

Consistent tagging was applied automatically using Bicep.

Tags included:

  • Environment

  • Owner

  • Project

  • Cost model

This improves governance, cost reporting, and long-term manageability.

Key Takeaway

Infrastructure as Code enables teams to deploy scalable, secure, and repeatable Azure environments.

By combining Bicep with sound network design and load balancing, this lab demonstrates how production-ready architectures can be built efficiently without sacrificing control.

Leave a Comment

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