Microsoft Azure

Public Load Balancer in Azure Step By Step

Public Load Balancers in this blog I am going to show you how to set up a public load balancer in Azure. Distribute the incoming traffic over multiple servers. Here, it will divide up the load over two Virtual Machines.

Create Virtual Machines

Create VMs in each virtual network (VNet) so that we can communicate between them.

1st VM

1- On the Azure portal menu tab, select Virtual machines

microsoft azure menu

2- Select the + Add button to create virtual machine.

azure virtual machine

3- Resource group select create new.

azure create a new virtual machine

4- Type resource group name (rg-web) and then click OK.

azure resource group name

5- Instance details
Enter a virtual machine name (web1)
Region select (East US)
Availability options – select Availability set.
Availability set select to create new.

azure new vm wizard

6- Enter a Availability set name (loadbalanceset) and then click OK.

azure create availability set

7- Image select Windows Server 2019 Datacenter.

You can select a various operating system, but the remaining steps assume you selected Windows Server 2019 Datacenter.

azure instance details

8- Administrator account
Enter a username (jamil), Password.
Public inbound ports choose to allow selected ports.
Select inbound ports (HTTP, HTTPS, RDP) and then click on Review + create >

azure create new vm wizard

9- Select create

azure create vm review + create

Create the second VM

10- Complete steps 2-9 again, with the following changes:

NameValue
Resource grouprg-web
Virtual machine nameweb2
Region(US) West US
Availability optionsAvailability set
Availability setloadbalanceset
ImageWindows Server 2019 Datacenter
Administrator accountusername password
Public inbound portallow selected ports
Select inbound portsHTTP, HTTPS, RDP
Create 

11- The VMs take a few minutes to create. Now the both VMs (web1, web2) successfully created.

azure vm overview

Create Network Load Balancer

1- Select Microsoft Azure menu bat and then select Load Balancers

microsoft azure menu

2- Select create load balancer.

azure create load balancer

3- Select resource group (rg-web)

azure create load balancer

4- Enter the name of Load Balancer, select Region (East US), keep it Public and SKU Basic. Set the Public Address. Create new, enter a name (lbpublicip) keep it dynamic and then select Review + create >.

azure create load balancer

5- Click on Create.

azure create load balancer validation

6- Now you can see load balancer successfully created, click on (lbweb)

azure create load balancer validation

First, I am going to configure Health Probes for our Load Balancer. So, we want to specify how many servers we want to make the Load Balancer.
In the Backend Pools, we specify the servers which we are going to use in the Load Balancer.

Backend Pools

7- Click on Backend Pools and then click on + Add.

azure load balancer backend pool

8- Add backend pool wizard, Type a name
Virtual network (rg-web)
Associate to select virtual machines and then click the add button under a virtual machine.

azure add backend pool

9- Add virtual machine to backend pool wizard; Select the VMs and then click add.

azure add vm to backend pool

10- After selecting the VMs, then click on Add.

azure add vm to backend pool

11- The backend pool has been configured successfully. Inside Load Balancer, go to Health Probes

azure backend pool

12- Click on Add.

azure health probe

13- Enter a name to the Health Probe.
Protocol (HTTP)
The interval shows that it is going to make a probing attempt at 5-second intervals. The unhealthy threshold shows that after 2 attempts failed probe, it is going to declare it as an unhealthy server. Click ok

azure add health probe

14- Health probe successfully created, click on Load Balancing Rules.

azure load balancer health probe

15- Click on + Add button

azure load balancing rule

16- Add load balancing rule wizard, The IP version is IPv4
Select frontend IP Address
The protocol is TCP, the port number is 80
Backend port is 80, the backend pool is the one that we have just created and the health probe is the one that we have created.
Session persistence is by default – None
Idle timeout is by default – 4 minutes.
Floating IP disabled. Click on OK.

azure add load balancing rule

17- Load Balancing Rule has been created.

azure load balancing rule

Now we need to install Web Server IIS roles on both the VMs (web1, web2)

How to install web server IIS.

Test Network Load Balancer

After installing web server IIS roles on both VMs.
1- Open directory C:\inetpub\wwwroot\ on each VM and then delete these files.

windows explorer wwwroot

2- Right-click, select new and then click text documents.

windows explorer

3- Open the text file.

windows explorer wwwroot

4- Type this is windows server web1
Select file and then save as.

notepad

5- Type index.html Save as type (All Files) and click save.

windows explorer wwwroot

6- Select Azure menu and then load balancers.

microsoft azure menu

7- Click on load balancer (lbweb)

azure load balancer

8- In the Load Balancer, I have my Public IP address (lbpublicip). Copy it and paste it in the explorer address bar.

azure load balancer overview

9- On the first hit, it has taken me to web1 server.

azure load balancer test

10- Wait for 4 minutes then hit enter again, it is take you to web2 server.

azure load balancer test

Jamil Parvez

Jamil Pervez works as a Network Administrator, based in Kuwait with a Primary focus on Microsoft technologies. Microsoft Certified MCSE, MCTP, MCITP, CCNP, CCIP, CCVP with 20 years of experience in administering Windows Servers, Exchange, VMWare, Veeam B&R, Veritas BackupExec.

Related Articles

Leave a Reply

Back to top button