DEV Community

Cover image for Setting Up a Load Balancer in Azure
Sandra Brown for SkillTech Club

Posted on

Setting Up a Load Balancer in Azure

When your web app starts getting traffic, your single server might begin to struggle. That’s when you know it’s time to scale and scaling means load balancing. If you're working in the Azure cloud Microsoft offers a powerful set of native load balancing tools to help you distribute traffic across your backend resources.
Keep reading, you'll get to know everything you need to know to set up your first Azure Load Balancer. Whether you're preparing for real-world cloud architecture or studying for AZ-104 or AZ-305.

What Is Load Balancing, and Why Is It Important?

Load balancing is the practice of distributing incoming network traffic across multiple servers. The goal? Improve performance, minimize downtime, and ensure no single resource is overworked.

In Azure, load balancing helps you:
Handle increasing user traffic
Improve application availability
Reduce latency by routing requests smartly
Add redundancy

Types of Load Balancers in Azure

Before jumping into setup, it’s important to understand that Azure offers more than one type of load balancer. Your choice depends on the scenario and requirement.

1. Azure Load Balancer (Standard or Basic)

Works at Layer 4 (Transport layer)

Distributes TCP/UDP traffic

Ideal for internal traffic or VM-level load balancing

Offers outbound SNAT, health probes, and high availability

2. Azure Application Gateway

Works at Layer 7 (Application layer)

Can route based on URLs, host headers, etc.

Supports SSL termination and Web Application Firewall

3. Traffic Manager

DNS-based global routing

Routes users to nearest regional deployment

Good for geo-redundant applications

Here, we’ll focus on the Standard Azure Load Balancer, which is widely used for VM scenarios.

Example: Load Balancing Two Web Servers

You have two virtual machines hosting your web app. You want to distribute incoming traffic equally across them using a load balancer.

Setting Up Azure Load Balancer

Step 1: Create Virtual Machines (Backend Pool)
Let’s start by creating two or more virtual machines that will serve as your backend servers.

You can use Azure Portal, Azure CLI, or PowerShell. Here, we’ll use the Azure Portal.

Go to the Azure Portal.

Navigate to Virtual Machines > Create VM.

Create two VMs (e.g., webvm1 and webvm2) in the same Virtual Network and Availability Set.

Install IIS or a web app on both VMs so you can test them later

Step 2: Create an Azure Load Balancer
Go to Create a resource > Networking > Load Balancer.

Choose Standard Load Balancer.

Set:

Frontend IP Configuration: Public or Private (we’ll choose Public for now).

Region: Same as your VMs.

Click Review + Create and then Create.

Step 3: Define Backend Pool
Now that your load balancer is ready, you need to define which VMs it will distribute traffic to.

Navigate to your Load Balancer > Backend Pools.

Click + Add.

Select the VMs (webvm1 and webvm2).

Make sure they are in the same Availability Set.

Step 4: Create Health Probe
Health probes help Azure check whether your VMs are healthy. Only healthy instances receive traffic.

Navigate to Health Probes in your load balancer.

Click + Add.

Choose:

Protocol: HTTP

Port: 80

Path: / (or whatever your app’s health endpoint is)

Save it.

Step 5: Set Load Balancing Rules
Now you decide what traffic the load balancer should distribute.

Go to Load Balancing Rules > + Add.

Define:

Name: web-rule

Frontend IP: Your public IP

Backend Pool: The one with your VMs

Protocol: TCP

Port: 80

Health Probe: The one you created

Save.

Cool! You’ve now created a fully functional load balancer.

Testing the Setup

To test, visit the public IP of your load balancer in a browser:
http://<your-loadbalancer-ip>
Refresh the page a few times. If both VMs have unique content, you’ll notice the requests switching between them.

Advanced Configurations (Optional)

Azure Load Balancer also supports:

Inbound NAT rules for remote VM access
Outbound rules for internet traffic
Floating IP for active-passive configurations
Multiple frontend IPs for multitenancy

If you're preparing for Azure certification or real-world architecture, these features are worth exploring.

Best Practices

Use Availability Sets or VM Scale Sets to ensure high availability.

Always define a Health Probe to avoid routing to unhealthy VMs.

Use Network Security Groups to restrict traffic to only needed ports.

For SSL or layer 7 routing, use Application Gateway instead.

How to Learn More?

Understanding Azure networking is a critical skill for modern DevOps, developers, and cloud engineers. If you're looking to master the end to end of Azure Load Balancers, VNets, NAT, ExpressRoute, and VPN Gateways, there’s a structured way to do it. Explore the Microsoft Azure Administrator Course at SkillTech Club.

Final Thoughts

Azure Load Balancer is more than just a traffic director. it's a foundational service that allows your apps to scale, stay resilient, and respond faster to user demands. Even if you’re just starting or looking to sharpen your Azure networking knowledge, mastering load balancing is an essential step.

Set it up once. You’ll be surprised how fast it becomes second nature and how much performance, reliability, and scalability your apps gain in return.

Top comments (2)

Collapse
 
canvascloudai profile image
Kevin Brown

Nice overview. Sandra, please try this on our platform. Feedback is welcomed.

Collapse
 
sandrabrown profile image
Sandra Brown SkillTech Club

Sure, I'm on it