Introduction / Issue:
In Azure environments, load balancers are used to distribute incoming traffic across multiple virtual machines (VMs). A common issue occurs when newly added VMs don’t receive traffic because they’re not properly linked to the Load Balancer’s backend pool. This leads to failed connections or uneven load distribution.
Why we need to do / Cause of the issue:
When applications are scaled by adding more VMs, traffic must be balanced across them to ensure availability and performance. If these VMs are not associated with the Load Balancer, the system cannot route traffic to them. This often happens when VMs are deployed after the Load Balancer setup or if configurations are skipped.
How do we solve:
Follow these steps to add VMs to the Azure Load Balancer:
- Access Load Balancer:
- Go to Azure Portal → Load Balancers → Select your Load Balancer.
Add to Backend Pool:
- Go to Backend pools → + Add
- Name it (e.g., WebPool), select the correct Virtual Network
- Choose Virtual Machines as backend type
- Select the VMs and their IP configurations → Click Add
- Configure Health Probe:
- Go to Health probes → + Add
- Set protocol (TCP/HTTP), port (e.g., 80), and thresholds → Save
- Set Load Balancing Rule:
- Go to Load balancing rules → + Add
- Set Frontend IP, Backend Pool, Protocol/Port, Health Probe
- Adjust session settings → Save
- Test Connectivity:
- Use browser or curl to access the Load Balancer’s frontend IP
- Verify traffic is routed to all backend VMs
Conclusion:
By associating new VMs with the backend pool, configuring health checks, and setting up load balancing rules, we ensured traffic is correctly distributed. This approach maintained high availability and allowed seamless scaling of the application without downtime.