Configure Azure Public Load Balancer Part -2

This is part-2 of previous article and we are configuring a public load balancer in Azure which for distributing/load balancing traffic between VMs where we host an application or service.

Please read Part-1 before going through steps in this article.

In Part-1 lab, we have added two VMs (Windows Server 2016), specified Virtual Network, configured Availability sets and their public IPs. We also did setup and deploy a web application on IIS in both VMs and tested accessing those using individual URLs.

In Azure portal, add a load balancer as shown below:


Choose the type of load balancer as “Public”



Next step is to select new Load Balancer that is created and go to “Front end IP configuration” and add a public IP address. Note that once completed, we will be using this IP address for accessing the web application (MyWebApp that we created in Part-1 lab) instead of individual IPs for VMs.



Select “Backend Pools” next and click “Add”. Select your availability set where both of our VMs are associated.




Now you will be able to associate  both VMs to the backend pool of load balancer as shown below.


Once done, go to Health Probes, and add a health probe for this load balancer with default settings.

The next important step is to set Load balancing rules. Add one as shown below.



Go to LoadBalancer Front End and you can find the public IP address has been associated and configuration is looking good



Now it is time to test accessing your web application. Note that we access the web application using  LoadBalancer public IP.

http://<load balancer IP address>/MyWebApp

The demo below shows the results when I accessed it using two browser instances. Loadbalancer directed one to VM1 and the other to VM2



Assume that one of your Virtual Machine is down or under maintenance, the load balancer auromatically redirects the traffic to other available VMs. In our case, I have stopped VM1 (WebServerVM1) to simulate such a scenario.


Once VM is stopped, refresh the browser instance which was loaded from that VM1. Note that the load balancer redirects the request to VM2 as shown below.


Details of internal load balancing scenarios will be discussed in another article.


Configure Azure Public Load Balancer Part -1

It has been several months since I covered Azure topics here. As we revisit Azure, I would like to start with Load Balancer.


Microsoft Azure provides load balancer options for the following :

  • Load balance external traffic to your VMs (Public Load Balancer or External Load Balancer)
  • Load balance traffic inside your Azure virtual network (Internal Load Balancer)
  • Port forward traffic to a specific port on specific VMs

Note : If you are looking for how to distribute traffic between different data centers/regions, explore Azure Traffic Manager.

In this article, we will configure an external load balancer. This requires you to create couple of VMs in your Azure account and configure IIS and a web applicationon it first, which is covered in Part-1 here.

First create two VMs. In this case, I selected Windows Server 2016. I named them as WebServerVM1, WebServerVM2



Create an availability set as shown below:


Create Virtual Network (or use an existing one), and create and assign a public IP for both VMs. As shown below, now we have the VMs and the related resources created.


Next step is to remote (RDP) to both VMs. Then install and configure IIS on both using Server Manager.




On each VMs, add inbound rule in Windows Firewall to allow port 80.


Create demo application in IIS (named as MyWebApp in this example) on both VMs and place a simple HTML file as home page. For our demo, I added a text in html home page content to identify whether it is deployed in VM1 or VM2.


This completes our VM and application configuration on both VMs.

Going back to Azure portal; we also need to set Inbound Security Rule in Network Security Group for both VMs.

  • Select NSG resource.
  • Click on Inbound Security Rules
  • Add rule for port 80 as shown below


Once this is completed, you can access applications on both VMs using their individual URLs using their public IPs as demonstrated below.


Next step is to configure our public load balancer for these two VMs. We will explore that in our next lab/article.