Microsoft Azure Tutorials

How To Create an Azure Load Balancer – Lab9

In this tutorial you will learn how to create a Load Balancer in Azure. This lab I will walk you through the steps to deploy a load balancer to load balance virtual machine traffic.

What is an Azure Load Balancer?

  • An Azure load balancer provides high availability by distributing incoming traffic among healthy VMs and it works at Layer- 4 of OSI Reference Model using the TCP and UDP protocols to manage transaction traffic based on a simple load balancing algorithm and basic information such as server connections and response times.

Task Details

  1. Log into Azure Portal.
  2. Create a virtual network.
  3. Create NAT gateway.
  4. Create load balancer.
  5. Create 3 virtual machines.
  6. Install IIS.
  7. Test the load balancer.

Task 1: Log into Azure Portal

  1. Open a browser tab and go to the Azure portal using URL https://portal.azure.com.
  2. Sign in with your username and password on azure portal.

Task 2: Create a virtual network

1. From the Search field type in Virtual Network, afterwards select Virtual Networks.

2. From the Virtual Networks page click Create.

3. In the Basics tab fill out your Virtual Network details.

Project Details

  • Subscription:  Select your subscription
  • Resource Group: Create a group called AzureLab

Instance Details

  • Name: AzureLabVNET01
  • Region: Select one specific to you

4. Click the Next : IP addresses button.

5. In the IP Addresses tab lets enter the following

IPv4 address space

  • IPv4 address space: Enter 10.1.0.0/16
  • Click: Add subnet
  • Subnet Name: AzureLabSubnet
  • Subnet Address Rage: 10.1.0.0/24
  • Click the Add button.

6. Click the Next : Security button.

7. In the Security tab lets enter the following

  • BastionHost: Enable
  • Bastion Name: AzureLabBastionHost
  • AzureBastionSubnet: 10.1.1.0/27
  • Public IP Address: Create new, name it AzureLabPublicIP

8 Click the Review + Create button. Then click Create once validation passed.

Task 3: Create NAT gateway

1. From the Search field type in Nat Gateway, afterwards select Nat Gateways.

2. Click the Create button.

3. In the Basics tab fill out your NAT gateway details.

Project Details

  • Subscription:  Select your subscription
  • Resource Group: Select group called AzureLab

Instance Details

  • Nat gateway name: AzureLabNatGateway
  • Availability Zone: None
  • TCP idle timeout: 15

4. Click the Next : Outbound IP button.

5. In the Outbound IP tab lets enter the following.

  • Public IP addresses: Create New, name it AzureLABNATIP

6. Click the Next : Subnet button.

7. Now for the Subnet tab lets enter the following.

  • Virtual Network: Select AzureLabVNET01
  • Under Subnet Name: check AzureLabSubnet

8. Click the Review + Create button, followed by Create once successfully validated.

Task 4: Create Load Balancer

1. At the top of the Azure portal, enter Load balancer. Select Load balancers.

2.  Click the Create button.

3. In the Basics tab fill out your load balancer details.

Project Details

  • Subscription:  Select your subscription
  • Resource Group: Select group called AzureLab

Instance Details

  • Name: AzureLabLoadBalancer
  • Region: default selected
  • SKU: Standard
  • Type: Public
  • Tier: Regional

4. Click Next : Frontend IP Configuration button.

5. Now under the Frontend IP configuration Tab click Add a frontend IP configuration.

6. Lets apply the following details.

  • Name: AzureLabLoadBalancerFrontend
  • IP Version: IPv4
  • IP type: IP address
  • Public IP address: Create New and name it myAzureLabPublicIP
    • Availability: Zone-redundant
    • Routing preference: Microsoft Network
    • Click OK
  • Now select the Add button.

7. Click Next : Backend pools button.

8. Now under the Backend pools Tab click Add a backend pool and enter the following details.

  • Name: myAzureLabBackendPool
  • Virtual Network: AzureLabVNET01
  • Backend Pool Configuration: Nic
  • IP Version: IPv4

9. Click the Add button.

10. Click Next : Inbound rules button.

11. Now under the Inbound rules Tab enter the following details.

Click Add a load balancing rule.

  • Name: myAzureLABHTTPRule
  • IP Version: Select IPv4 or IPv6
  • Frontend IP address: Select AzureLabLoadBalancerFrontend
  • Protocol: Select TCP
  • Port: 80
  • Backend port: 80
  • Backend pool: Select myAzureLABBackendPool
  • Health probe:
    • Select Create new.
    • Name: myAzureLABHealthProbe
    • Protocol: HTTP
    • Select OK.
  • Session persistence: None
  • Idle timeout (minutes): 15
  • TCP reset: Enabled
  • Floating IP: Disabled

12. Now click the Add button.

13. Finally you can click the Review + Create button. Then click Create once validation passed.

Task 5: Create 3 Virtual Machines 

1. At the top of the Azure portal, enter Virtual Machine. Select Virtual machines.

From here click the Create dropdown and select Azure virtual machine.

3. In the Basics tab fill out your virtual machine details

Project Details

  • Subscription:  Select your subscription
  • Resource Group: Create a group called AzureLab

Instance Details

  • Virtual Machine Name: AzureLabVM01
  • Region: Select one specific to you
  • Availability options: Availability Zone
  • Availability options: Zones 1
  • Security Type: Standard
  • Image: Windows Server 2022 Datacenter: Azure Edition – Gen2
  • Size: Standard_B2s – 2 vcpu, 4GB memory

Administrator Account

  • Username: Enter a username
  • Password: Enter a strong password

Inbound port rules

  • Public inbound ports: None

4. Click Next: Disks> button.

5. In the Disks tab we will just make one setting change.

  • OS disk type: Premium SSD

6. Click the Next : Networking > button.

Network Interface

  • Virtual Network: AzureLabVNET01
  • Subnet: AzureLabSubnet
  • Public IP: None
  • Configure Network security group: Create New
    • Name: myAzureLabNSG
    • Click +Add an inbound rule
      • Source: Any
      • Source port ranges: *
      • Destination: Any
      • Service: HTTP
      • Action: Allow
      • Priority: 100
      • Name: myAzureLabNSGRule
      • Click the Add button.
    • Click the OK button. 

Load Balancing

  • Load balancing options: Azure load balancer
  • Select a load balancer: AzureLabLoadBalancer
  • Select backend pool: myAzureLabBackendPool

7. Select the Review + create button at the bottom of the page and then click on Create. After a few minutes, your VM will be deployed.

8. Now, follow the steps above to create two more VMs with the following values and all the other settings the same as AzureLabVM01:

  • For VM2:
    • Name: AzureLabVM02
    • Availability Zone: Zone 2
    • NSG: myAzureLabNSG
  • For VM3:
    • Name: AzureLabVM03
    • Availability Zone: Zone 3
    • NSG: myAzureLabNSG

Task 6: Install IIS

1. At the top of the Azure portal, enter Virtual Machine. Select Virtual machines.

2. Select AzureLabVM01. On the Overview page of AzureLabVM01 click on Connect, then Bastion.

3. Once logged in run PowerShell as an Administrator.

4. Enter the following command to install IIS.

Install-WindowsFeature -name Web-Server -IncludeManagementTools

5. Once IIS is installed enter the following command to auto start the IIS service.

Set-Service -name W3SVC -startupType Automatic

6. Remove default IIS landing page using the following command.

Remove-Item C:\inetpub\wwwroot\iisstart.htm

7. Create a new landing page with the following command, it will echo server name.

Add-Content -Path "C:\inetpub\wwwroot\iisstart.htm" -Value $("Hello World from " + $env:computername)

8. Close the Bastion session with AzureLabVM01and then repeat the above PowerShell steps to install IIS and the updated iisstart.htm file on AzureLabVM02 and AzureLabVM03.

 

Task 7: Test the load balancer

1. In the search field at the top of the Azure portal page, enter load balancer. Select Load balancers in the search results.

2. On the Overview page, under Public IP address, copy the public IP address, and then paste it into the address bar of your browser. The custom VM page of the IIS Web server is displayed in the browser.

3. If you refresh the page, you should see different Hello messages from the 3 servers.

You have successfully completed this lab on How To Create an Azure Load Balancer and even testing a deployment accessing HTTP. Remember to delete all that has been created.

I hope this article was helpful, if you have any questions, please feel free to contact me. If you would like to be notified of when I create a new post, you can subscribe to my blog alert.


Discover more from Patrick Domingues

Subscribe to get the latest posts sent to your email.

author avatar
Patrick Domingues

Leave a Comment

Stay Informed

Receive instant notifications when new content is released.