How to Configure an Azure Load Balancer?
Last Updated : 20 Sep, 2023
In this article, we will see how to set up a Load Balancer in Azure. Load Balancer is a component that splits or divides network traffic across multiple application servers. It helps in the high availability of applications. In this article, we will configure a public load balancer that is accessible through the Internet.
Introduction to Azure Load Balancer
Azure Load Balancer is a component in Azure that helps in uniform distribution of load across services. There are mainly two types of Azure load balancers public and internal. It provides load balancing across various virtual machines, scale sets, and IP addresses.
Types of Azure Load Balancers
- Public Load Balancer: A load balancer that is exposed to the internet is the public load balancer.
- Internal Load Balancer: A load balancer that is only available inside the network and not available through the internet is the internal load balancer. It is mainly used for internal traffic splitting.
Health Checks In Azure
Health checks in azure helps in rerouting the traffics to available resources if any of the other resources are not available. Health checks continuously check for availability of resources depending upon specified threshold and time . If it finds an unhealthy resource it forwards the traffic to other healthy resource .
Steps to configure load Balancer in Azure
- We will first create a virtual network with Bastion host . This network will contain our Azure virtual machine VM's . In the search box on azure portal search for virtual networks and then click create.
- Specify your subscription and name for virtual network in your required region . Then click next to security tab . Under security tab specify the options as below . specify name for bastion and create new public ip for the same.
> - On next tab "IP addresses" select starting address as '10.1.0.0' and address space as '\16' and then 'Add'. Now click on add new subnet . specify following fields . This is configuration for our Virtual machines subnet
- click add and again select add new subnet and specify options as below . This is configuration for subnet used by Bastion host .
.png)
- Now click on 'review+create' . Review the specified options and then click create.
- Now lets configure load balancer in virtual network . Search for load balancers in search . Click on create .
- On create page first select your subscription and then select resource group same as virtual network . Then select public load balancer and specify other options as below .
- Now go to next . Here click on add frontend ip configuration . Under frontend Ip configuration create new public ip address for frontend and make it zone redundant. specify other options as below.
- Click next on backend pools . Select add backend pool . Specify options as below and give backend pool a name. select virtual network we have created as virtual network .
- Now click next to configure inbound rules . on this page select add load balancing rule . Now specify options as below .
- Create a new health probe with below settings .
- Click save then click on review and create . After reviewing all the settings click on create.
- Once the deployment is successful lets create a NAT gateway for outbound access to bastion. Search for NAT gateways in search and click on create . Specify the options as below .
- Click next for outbound IP specification . Create a new public ip address and add it . Now review all configuration and click create . For subnet select backend subnet that we have created .
- Once the NAT is set up now we will create two virtual machines for web servers . Specify options as below for virtual machine .
- Specify user name and password for user . Select None for public inbound ports.
- Now click next to configure networking . On networking tab select our virtual network and set subnet as backend subnet . select none for public ip address . Now select 'Advanced' for NIC .
- Now scroll down to configure load balancing . Check 'Put this instance behind load balancer' once the option is selected configure load balancer . Select 'Azure Load balancer' under it select our created load balancer . The backend pool will be automatically selected .
- Now go up to configure network security group . Click on create new . Specify options as below . Create a new inbound rule with service as 'HTTP' and priority as 100 . Add rule to security group . Click OK.
- After adding security group click on review and create . Click create .
- Similarly follow above steps to create another virtual machine . Specify different name for vm2 . Select availability zone 2 for this vm . Make sure you select existing created network security group . After configuring click create .
- Once both virtual machines are created . Go to overview page of VM1 and click connect select Bastion . Enter Username and Password and connect to VM .
- On VM desktop search for powershell and run below commands one by one .
Install-WindowsFeature -name Web-Server -IncludeManagementTools
Remove-Item C:\inetpub\wwwroot\iisstart.htm
Add-Content -Path "C:\inetpub\wwwroot\iisstart.htm" -Value $("Hello World from " + $env:computername)
- If first command fails manually go to windows features options and Turn on "Internet Information Services" and "Internet Information Services Ho-stable web Core" features. After that run next two commands . Close the bastion tab .
- Do the same for VM2 .
- Now we have completed configuration of load balancer . Lets check the working .
- Search for public ip address in search bar . Now go to load balancer ip address . Copy and paste it in the browser you should see similar output as below . Every time you refresh the page it will be served from different virtual machines .
- If you see above output congratulations you have successfully configured Azure load balancer .
Troubleshooting
- If you dont see correct output then make sure you have configured the load balancer with correct IP addresses.
- Make sure your VM instances are in same region and resource group as load balancer .
- Make sure IP configuration for load balancer is correct .
Best practices for configuring Azure Load Balancer
There are various options for configuring Azure Load Balancer. You can also choose other services as Traffic Manager , Application Gateway, Azure Front Door .etc . For Load Balancer best way to configure is to use group of servers as backend.
Similar Reads
How To Configure GateWay Load Balancer In AWS ? In the advanced landscape of cloud computing, managing incoming internet traffic efficiently is fundamental for ensuring the accessibility, scalability, and reliability of applications. AWS offers a set of services to address these necessities, and one such help is the Gateway Load Balancer (GWLB).
7 min read
How to Create a Load Balancer on GCP? A load balancer in GCP (Google Cloud Platform) is a service that distributes incoming network traffic across multiple backend resources such as virtual machines (VMs), container instances, and managed instance groups. The main purpose of a load balancer is to improve the availability and scalability
5 min read
How to Create a Load Balancer and Connect it across 2 VMs? Load Balancer is basically defined as a distributing device that is used to distribute the work Processes into different systems/servers. It is generally used to control the traffic on one system by dividing the flow of traffic into different systems. In other words, A load balancer is a networking
5 min read
How to Install an SSL Certificate on Azure It is always more important for your web applications and services to ensure the transmission data security for users and protect personal information with HTTPS encryption. Microsoftâs cloud offering known as Azure offers several ways of deploying SSL & TLS certificates that would facilitate se
8 min read
Create and Configure: Mastering AWS Network Load Balancer Essentials In the domain of distributed computing, compelling administration of network traffic is fundamental for keeping up with the presentation, dependability, and versatility of utilizations. Amazon Web Services (AWS), a main cloud specialist organization, offers the Network Load Balancer (NLB) as an esse
14 min read