HOL : Create a public load balancer to load balance VMs using the Azure portal

Get started with Azure Load Balancer by using the Azure portal to create a public load balancer and three virtual machines.

In this section, you create a load balancer that load balances virtual machines.

When you create a public load balancer, you create a new public IP address that is configured as the frontend (named as LoadBalancerFrontend by default) for the load balancer.

  1. On the top left-hand side of the screen, select Create a resource > Networking > Load Balancer.
  2. In the Basics tab of the Create load balancer page, enter, or select the following information:

3. Accept the defaults for the remaining settings, and then select Review + create.

4. In the Review + create tab, select Create.

Create load balancer resources

In this section, you configure:

  • Load balancer settings for a backend address pool.
  • A health probe.
  • A load balancer rule.

Create a backend pool

A backend address pool contains the IP addresses of the virtual (NICs) connected to the load balancer.

Create the backend address pool myBackendPool to include virtual machines for load-balancing internet traffic.

  1. Select All services in the left-hand menu, select All resources, and then select myLoadBalancer from the resources list.
  2. Under Settings, select Backend pools, then select Add.
  3. On the Add a backend pool page, for name, type myBackendPool, as the name for your backend pool, and then select Add.

Create a health probe

The load balancer monitors the status of your app with a health probe.

The health probe adds or removes VMs from the load balancer based on their response to health checks.

Create a health probe named myHealthProbe to monitor the health of the VMs.

  1. Select All services in the left-hand menu, select All resources, and then select myLoadBalancer from the resources list.
  2. Under Settings, select Health probes, then select Add.

3. Leave the rest the defaults and Select OK.

Create a load balancer rule

A load balancer rule is used to define how traffic is distributed to the VMs. You define the frontend IP configuration for the incoming traffic and the backend IP pool to receive the traffic. The source and destination port are defined in the rule.

In this section, you’ll create a load balancer rule:

  • Named myHTTPRule.
  • In the frontend named LoadBalancerFrontEnd.
  • Listening on Port 80.
  • Directs load balanced traffic to the backend named myBackendPool on Port 80.
  1. Select All services in the left-hand menu, select All resources, and then select myLoadBalancer from the resources list.
  2. Under Settings, select Load-balancing rules, then select Add.
  3. Use these values to configure the load-balancing rule:

4. Leave the rest of the defaults and then select OK.

Create backend servers

In this section, you:

  • Create a virtual network.
  • Create three virtual machines for the backend pool of the load balancer.
  • Install IIS on the virtual machines to test the load balancer.

Create the virtual network

In this section, you’ll create a virtual network and subnet.

  1. On the upper-left side of the screen, select Create a resource > Networking > Virtual network or search for Virtual network in the search box.
  2. In Create virtual network, enter or select this information in the Basics tab:

3. Select the IP Addresses tab or select the Next: IP Addresses button at the bottom of the page.

4. In the IP Addresses tab, enter this information:

5. Under Subnet name, select the word default.

6. In Edit subnet, enter this information:

7. Select Save.

8. Select the Security tab.

9. Under BastionHost, select Enable. Enter this information:

10. Select the Review + create tab or select the Review + create button.

11. Select Create.

Create virtual machines

In this section, you’ll create three VMs (myVM1, myVM2 and myVM3) in three different zones (Zone 1, Zone 2, and Zone 3).

These VMs are added to the backend pool of the load balancer that was created earlier.

  1. On the upper-left side of the portal, select Create a resource > Compute > Virtual machine.
  2. In Create a virtual machine, type or select the values in the Basics tab:

3. Select the Networking tab, or select Next: Disks, then Next: Networking.

4. In the Networking tab, select or enter:

5. Select the Management tab, or select Next > Management.

6. In the Management tab, select or enter:

7. Select Review + create.

8. Review the settings, and then select Create.

9. Follow the steps 1 to 8 to create two additional VMs with the following values and all the other settings the same as myVM1:

Create outbound rule configuration

Load balancer outbound rules configure outbound SNAT for VMs in the backend pool.

For more information on outbound connections, see Outbound connections in Azure.

Create outbound rule

  1. Select All services in the left-hand menu, select All resources, and then select myLoadBalancer from the resources list.
  2. Under Settings, select Outbound rules, then select Add.
  3. Use these values to configure the outbound rules:

4. Select Add.

Add virtual machines to outbound pool

  1. Select All services in the left-hand menu, select All resources, and then select myLoadBalancer from the resources list.
  2. Under Settings, select Backend pools.
  3. Select myBackendPoolOutbound.
  4. In Virtual network, select myVNet.
  5. In Virtual machines, select + Add.
  6. Check the boxes next to myVM1, myVM2, and myVM3.
  7. Select Add.
  8. Select Save.

Install IIS

  1. Select All services in the left-hand menu, select All resources, and then from the resources list, select myVM1 that is located in the CreatePubLBQS-rg resource group.
  2. On the Overview page, select Connect, then Bastion.
  3. Enter the username and password entered during VM creation.
  4. Select Connect.
  5. On the server desktop, navigate to Windows Administrative Tools > Windows PowerShell.
  6. In the PowerShell Window, run the following commands to:
  • Install the IIS server
  • Remove the default iisstart.htm file
  • Add a new iisstart.htm file that displays the name of the VM:

# install IIS server role
Install-WindowsFeature -name Web-Server -IncludeManagementTools

# remove default htm file
remove-item C:\inetpub\wwwroot\iisstart.htm

# Add a new htm file that displays server name
Add-Content -Path “C:\inetpub\wwwroot\iisstart.htm” -Value $(“Hello World from “ + $env:computername)

7. Close the Bastion session with myVM1.

8. Repeat steps 1 to 6 to install IIS and the updated iisstart.htm file on myVM2 and myVM3.

est the load balancer

  1. Find the public IP address for the load balancer on the Overview screen. Select All services in the left-hand menu, select All resources, and then select myPublicIP.
  2. Copy the public IP address, and then paste it into the address bar of your browser. The default page of IIS Web server is displayed on the browser.

To see the load balancer distribute traffic across all three VMs, you can customize the default page of each VM’s IIS Web server and then force-refresh your web browser from the client machine.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store