title | titleSuffix | description | author | ms.author | ms.service | ms.topic | ms.date | ms.custom |
---|---|---|---|---|---|---|---|---|
Tutorial: Create a load balancer with more than one availability set in the backend pool - Azure portal |
Azure Load Balancer |
In this tutorial, deploy an Azure Load Balancer with more than one availability set in the backend pool. |
greg-lindsay |
greglin |
load-balancer |
tutorial |
05/09/2022 |
template-tutorial |
Tutorial: Create a load balancer with more than one availability set in the backend pool using the Azure portal
As part of a high availability deployment, virtual machines are often grouped into multiple availability sets.
Load Balancer supports more than one availability set with virtual machines in the backend pool.
In this tutorial, you learn how to:
[!div class="checklist"]
- Create a virtual network
- Create a NAT gateway for outbound connectivity
- Create a standard SKU Azure Load Balancer
- Create four virtual machines and two availability sets
- Add virtual machines in availability sets to backend pool of load balancer
- Test the load balancer
- An Azure account with an active subscription. Create an account for free.
In this section, you'll create a virtual network for the load balancer and the other resources used in the tutorial.
-
Sign in to the Azure portal.
-
In the search box at the top of the portal, enter Virtual network.
-
In the search results, select Virtual networks.
-
Select + Create.
-
In the Basics tab of the Create virtual network, enter, or select the following information:
Setting Value Project details Subscription Select your subscription. Resource group Select Create new.
Enter TutorLBmultiAVS-rg in Name.Instance details Name Enter myVNet. Region Select (US) West US 2. -
Select the IP addresses tab, or the Next: IP Addresses button at the bottom of the page.
-
In the IP Addresses tab, enter this information:
Setting Value IPv4 address space Enter 10.1.0.0/16 -
Select + Add subnet.
-
In Add subnet, enter this information:
Setting Value Subnet name Enter myBackendSubnet Subnet address range Enter 10.1.0.0/24 -
Select Add.
-
Select the Security tab, or the Next: Security button at the bottom of the page.
-
In the Security tab, in BastionHost select Enable.
-
Enter or select the following information:
Setting Value Bastion name Enter MyBastionHost. AzureBastionSubnet address space Enter 10.1.1.0/27. Public IP address Select Create new.
Enter myBastionIP in Name. -
Select the Review + create tab, or the blue Review + create button at the bottom of the page.
-
Select Create.
In this section, you'll create a NAT gateway for outbound connectivity of the virtual machines.
-
In the search box at the top of the portal, enter NAT gateway.
-
Select NAT gateways in the search results.
-
Select + Create.
-
In the Basics tab of Create network address translation (NAT) gateway, enter or select the following information:
Setting Value Project details Subscription Select your subscription. Resource group Select TutorLBmultiAVS-rg. Instance details NAT gateway name Enter myNATgateway. Region Select (US) West US 2. Availability zone Select None. Idle timeout (minutes) Enter 15. -
Select the Outbound IP tab, or select the Next: Outbound IP button at the bottom of the page.
-
Select Create a new public IP address next to Public IP addresses in the Outbound IP tab.
-
Enter myNATgatewayIP in Name.
-
Select OK.
-
Select the Subnet tab, or select the Next: Subnet button at the bottom of the page.
-
Select myVNet in the pull-down menu under Virtual network.
-
Select the check box next to myBackendSubnet.
-
Select the Review + create tab, or select the blue Review + create button at the bottom of the page.
-
Select Create.
In this section, you'll create a load balancer for the virtual machines.
-
In the search box at the top of the portal, enter Load balancer. Select Load balancers in the search results.
-
In the Load balancer page, select Create.
-
In the Basics tab of the Create load balancer page, enter, or select the following information:
Setting Value Project details Subscription Select your subscription. Resource group Select TutorLBmultiAVS-rg. Instance details Name Enter myLoadBalancer Region Select (US) West US 2. Type Select Public. SKU Leave the default Standard. Tier Leave the default Regional. -
Select the Frontend IP configuration tab, or select the Next: Frontend IP configuration button at the bottom of the page.
-
In Frontend IP configuration, select + Add a frontend IP configuration.
-
Enter LoadBalancerFrontend in Name.
-
Select IPv4 or IPv6 for the IP version.
[!NOTE] IPv6 isn't currently supported with Routing Preference or Cross-region load-balancing (Global Tier).
-
Select IP address for the IP type.
[!NOTE] For more information on IP prefixes, see Azure Public IP address prefix.
-
Select Create new in Public IP address.
-
In Add a public IP address, enter myPublicIP-lb for Name.
-
Select Zone-redundant in Availability zone.
[!NOTE] In regions with Availability Zones, you have the option to select no zone (default option), a specific zone, or zone-redundant. The choice will depend on your specific domain failure requirements. In regions without Availability Zones, this field won't appear.
For more information on availability zones, see Availability zones overview. -
Leave the default of Microsoft Network for Routing preference.
-
Select OK.
-
Select Add.
-
Select the Backend pools tab, or select the Next: Backend pools button at the bottom of the page.
-
In the Backend pools tab, select + Add a backend pool.
-
Enter myBackendPool for Name in Add backend pool.
-
Select myVNet in Virtual network.
-
Select NIC or IP Address for Backend Pool Configuration.
-
Select IPv4 or IPv6 for IP version.
-
Select Add.
-
Select the Inbound rules tab, or select the Next: Inbound rules button at the bottom of the page.
-
In Load balancing rule in the Inbound rules tab, select + Add a load balancing rule.
-
In Add load balancing rule, enter or select the following information:
Setting Value Name Enter myHTTPRule IP Version Select IPv4 or IPv6 depending on your requirements. Frontend IP address Select LoadBalancerFrontend. Protocol Select TCP. Port Enter 80. Backend port Enter 80. Backend pool Select myBackendPool. Health probe Select Create new.
In Name, enter myHealthProbe.
Select HTTP in Protocol.
Leave the rest of the defaults, and select OK.Session persistence Select None. Idle timeout (minutes) Enter or select 15. TCP reset Select Enabled. Floating IP Select Disabled. Outbound source network address translation (SNAT) Leave the default of (Recommended) Use outbound rules to provide backend pool members access to the internet. -
Select Add.
-
Select the blue Review + create button at the bottom of the page.
-
Select Create.
[!NOTE] In this example we created a NAT gateway to provide outbound Internet access. The outbound rules tab in the configuration is bypassed as it's optional and isn't needed with the NAT gateway. For more information on Azure NAT gateway, see What is Azure Virtual Network NAT? For more information about outbound connections in Azure, see Source Network Address Translation (SNAT) for outbound connections
In this section, you'll create two availability groups with two virtual machines per group. These machines will be added to the backend pool of the load balancer during creation.
-
Select + Create a resource in the upper left-hand section of the portal.
-
In New, select Compute > Virtual machine.
-
In the Basics tab of Create a virtual machine, enter, or select the following information:
Setting Value Project details Subscription Select your subscription Resource group Select TutorLBmultiAVS-rg. Instance details Virtual machine name Enter myVM1. Region Select (US) West US 2. Availability options Select Availability set. Availability set Select Create new.
Enter myAvailabilitySet1 in Name.
Select OK.Image Select Windows Server 2019 Datacenter - Gen1. Azure Spot instance Leave the default of unchecked. Size Select a size for the virtual machine. Administrator account Username Enter a username. Password Enter a password. Inbound port rules Public inbound ports Select None. -
Select the Networking tab, or select the Next: Disks, then Next: Networking button at the bottom of the page.
-
In the Networking tab, enter or select the following information:
Setting Value Network interface Virtual network Select myVNet. Subnet Select myBackendSubnet. Public IP Select None. NIC network security group Select Advanced. Configure network security group Select Create new.
In Name, enter myNSG.
Select +Add an inbound rule in Inbound rules.
Select HTTP for Service.
Enter myHTTPrule for Name.
Select Add.
Select OK.Load balancing Place this virtual machine behind an existing load-balancing solution? Select the check box. Load-balancing settings Load-balancing options Select Azure load balancer. Select a load balancer Select myLoadBalancer. Select a backend pool Select myBackendPool. -
Select the Review + create tab, or select the blue Review + create button at the bottom of the page.
-
Select Create.
-
Repeat steps 1 through 7 to create the second virtual machine of the set. Replace the settings for the VM with the following information:
Setting Value Name Enter myVM2. Availability set Select myAvailabilitySet1. Virtual Network Select myVNet. Subnet Select myBackendSubnet. Public IP Select None. Network security group Select myNSG. Load-balancing options Select Azure load balancer. Select a load balancer Select myLoadBalancer. Select a backend pool Select myBackendPool.
-
Select + Create a resource in the upper left-hand section of the portal.
-
In New, select Compute > Virtual machine.
-
In the Basics tab of Create a virtual machine, enter, or select the following information:
Setting Value Project details Subscription Select your subscription Resource group Select TutorLBmultiAVS-rg. Instance details Virtual machine name Enter myVM3. Region Select (US) West US 2. Availability options Select Availability set. Availability set Select Create new.
Enter myAvailabilitySet2 in Name.
Select OK.Image Select Windows Server 2019 Datacenter - Gen1. Azure Spot instance Leave the default of unchecked. Size Select a size for the virtual machine. Administrator account Username Enter a username. Password Enter a password. Inbound port rules Public inbound ports Select None. -
Select the Networking tab, or select the Next: Disks, then Next: Networking button at the bottom of the page.
-
In the Networking tab, enter or select the following information:
Setting Value Network interface Virtual network Select myVNet. Subnet Select myBackendSubnet. Public IP Select None. NIC network security group Select Advanced. Configure network security group Select myNSG. Load balancing Place this virtual machine behind an existing load-balancing solution? Select the check box. Load-balancing settings Load-balancing options Select Azure load balancer. Select a load balancer Select myLoadBalancer. Select a backend pool Select myBackendPool. -
Select the Review + create tab, or select the blue Review + create button at the bottom of the page.
-
Select Create.
-
Repeat steps 1 through 7 to create the second virtual machine of the set. Replace the settings for the VM with the following information:
Setting Value Name Enter myVM4. Availability set Select myAvailabilitySet2. Virtual Network Select myVNet. Network security group Select myNSG. Load-balancing options Select Azure load balancer. Select a load balancer Select myLoadBalancer. Select a backend pool Select myBackendPool.
In this section, you'll use the Azure Bastion host you created previously to connect to the virtual machines and install IIS.
-
In the search box at the top of the portal, enter Virtual machine.
-
Select Virtual machines in the search results.
-
Select myVM1.
-
In the Overview page of myVM1, select Connect > Bastion.
-
Enter the Username and Password you created when you created the virtual machine.
-
Select Connect.
-
On the server desktop, navigate to Windows Administrative Tools > Windows PowerShell.
-
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)
-
Close the Bastion session with myVM1.
-
Repeat steps 1 through 8 for myVM2, myVM3, and myVM4.
In this section, you'll discover the public IP address of the load balancer. You'll use the IP address to test the operation of the load balancer.
-
In the search box at the top of the portal, enter Public IP.
-
Select Public IP addresses in the search results.
-
Select myPublicIP-lb.
-
Note the public IP address listed in IP address in the Overview page of myPublicIP-lb:
:::image type="content" source="./media/tutorial-multi-availability-sets-portal/find-public-ip.png" alt-text="Find the public IP address of the load balancer." border="true":::
-
Open a web browser and enter the public IP address in the address bar:
:::image type="content" source="./media/tutorial-multi-availability-sets-portal/verify-load-balancer.png" alt-text="Test load balancer with web browser." border="true":::
-
Select refresh in the browser to see the traffic balanced to the other virtual machines in the backend pool.
If you're not going to continue to use this application, delete the load balancer and the supporting resources with the following steps:
-
In the search box at the top of the portal, enter Resource group.
-
Select Resource groups in the search results.
-
Select TutorLBmultiAVS-rg.
-
In the overview page of TutorLBmultiAVS-rg, select Delete resource group.
-
Enter TutorLBmultiAVS-rg in TYPE THE RESOURCE GROUP NAME.
-
Select Delete.
In this tutorial, you:
- Created a virtual network and Azure Bastion host.
- Created an Azure Standard Load Balancer.
- Created two availability sets with two virtual machines per set.
- Installed IIS and tested the load balancer.
Advance to the next article to learn how to create a cross-region Azure Load Balancer:
[!div class="nextstepaction"] Create a cross-region load balancer