title | titleSuffix | description | services | documentationcenter | author | manager | Customer intent | ms.service | ms.devlang | ms.topic | ms.tgt_pltfrm | ms.workload | ms.date | ms.author | ms.custom |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Quickstart: Create a public load balancer - Azure portal |
Azure Load Balancer |
This quickstart shows how to create a load balancer by using the Azure portal. |
load-balancer |
na |
asudbring |
KumudD |
I want to create a load balancer so that I can load balance internet traffic to VMs. |
load-balancer |
na |
quickstart |
na |
infrastructure-services |
07/17/2020 |
allensu |
mvc |
Get started with Azure Load Balancer by using the Azure portal to create a public load balancer and three virtual machines.
- An Azure account with an active subscription. Create an account for free.
Sign in to the Azure portal at https://portal.azure.com.
Note
Standard SKU load balancer is recommended for production workloads. For more information about SKUs, see Azure Load Balancer SKUs.
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.
-
On the top left-hand side of the screen, select Create a resource > Networking > Load Balancer.
-
In the Basics tab of the Create load balancer page, enter, or select the following information:
Setting Value Subscription Select your subscription. Resource group Select Create new and enter myResourceGroupLB in the text box. Name Enter myLoadBalancer Region Select West Europe. Type Select Public. SKU Select Standard Public IP address Select Create new. If you have an existing Public IP you would like to use, select Use existing. Public IP address name Type myPublicIP in the text box. Availability zone Select Zone-redundant to create a resilient load balancer. To create a zonal load balancer, select a specific zone from 1, 2, or 3 Add a public IPv6 address Select No.
For more information on IPv6 addresses and load balancer, see What is IPv6 for Azure Virtual Network? -
Accept the defaults for the remaining settings, and then select Review + create.
-
In the Review + create tab, select Create.
:::image type="content" source="./media/quickstart-load-balancer-standard-public-portal/create-standard-load-balancer.png" alt-text="Create a standard load balancer" border="true":::
In this section, you configure:
- Load balancer settings for a backend address pool.
- A health probe.
- A load balancer rule.
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.
-
Select All services in the left-hand menu, select All resources, and then select myLoadBalancer from the resources list.
-
Under Settings, select Backend pools, then select Add.
-
On the Add a backend pool page, for name, type myBackendPool, as the name for your backend pool, and then select Add.
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.
-
Select All services in the left-hand menu, select All resources, and then select myLoadBalancer from the resources list.
-
Under Settings, select Health probes, then select Add.
Setting Value Name Enter myHealthProbe. Protocol Select HTTP. Port Enter 80. Interval Enter 15 for number of Interval in seconds between probe attempts. Unhealthy threshold Select 2 for number of Unhealthy threshold or consecutive probe failures that must occur before a VM is considered unhealthy. -
Leave the rest the defaults and Select OK.
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.
-
Select All services in the left-hand menu, select All resources, and then select myLoadBalancer from the resources list.
-
Under Settings, select Load balancing rules, then select Add.
-
Use these values to configure the load-balancing rule:
Setting Value Name Enter myHTTPRule. IP Version Select IPv4 Frontend IP address Select LoadBalancerFrontEnd Protocol Select TCP. Port Enter 80. Backend port Enter 80. Backend pool Select myBackendPool. Health probe Select myHealthProbe. Create implicit outbound rules Select No. -
Leave the rest of the defaults and then select OK.
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.
In this section, you'll create a virtual network and subnet.
-
On the upper-left side of the screen, select Create a resource > Networking > Virtual network or search for Virtual network in the search box.
-
In Create virtual network, enter or select this information in the Basics tab:
Setting Value Project Details Subscription Select your Azure subscription Resource Group Select myResourceGroupLB Instance details Name Enter myVNet Region Select West Europe -
Select the IP Addresses tab or select 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 -
Under Subnet name, select the word default.
-
In Edit subnet, enter this information:
Setting Value Subnet name Enter myBackendSubnet Subnet address range Enter 10.1.0.0/24 -
Select Save.
-
Select the Security tab.
-
Under BastionHost, select Enable. Enter this information:
Setting Value Bastion name Enter myBastionHost AzureBastionSubnet address space Enter 10.1.1.0/24 Public IP Address Select Create new.
For Name, enter myBastionIP.
Select OK. -
Select the Review + create tab or select the Review + create button.
-
Select Create.
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.
-
On the upper-left side of the portal, select Create a resource > Compute > Virtual machine.
-
In Create a virtual machine, type or select the values in the Basics tab:
Setting Value Project Details Subscription Select your Azure subscription Resource Group Select myResourceGroupLB Instance details Virtual machine name Enter myVM1 Region Select West Europe Availability Options Select Availability zones Availability zone Select 1 Image Select Windows Server 2019 Datacenter Azure Spot instance Select No Size Choose VM size or take default setting Administrator account Username Enter a username Password Enter a password Confirm password Reenter password Inbound port rules Public inbound ports Select None -
Select the Networking tab, or select Next: Disks, then Next: Networking.
-
In the Networking tab, select or enter:
Setting Value Network interface Virtual network myVNet Subnet myBackendSubnet Public IP Select None. NIC network security group Select Advanced Configure network security group Select Create new.
In the Create network security group, enter myNSG in Name.
Under Inbound rules, select +Add an inbound rule.
Under Destination port ranges, enter 80.
Under Priority, enter 100.
In Name, enter myHTTPRule
Select Add
Select OKLoad balancing Place this virtual machine behind an existing load balancing solution? Select Yes Load balancing settings Load balancing options Select Azure load balancing Select a load balancer Select myLoadBalancer Select a backend pool Select myBackendPool -
Select the Management tab, or select Next > Management.
-
In the Management tab, select or enter:
Setting Value Monitoring Boot diagnostics Select Off -
Select Review + create.
-
Review the settings, and then select Create.
-
Follow the steps 1 to 8 to create two additional VMs with the following values and all the other settings the same as myVM1:
Setting VM 2 VM 3 Name myVM2 myVM3 Availability zone 2 3 Network security group Select the existing myNSG Select the existing myNSG
Load balancer outbound rules configure outbound SNAT for VMs in the backend pool.
For more information on outbound connections, see Outbound connections in Azure.
-
Select All services in the left-hand menu, select All resources, and then select myLoadBalancer from the resources list.
-
Under Settings, select Outbound rules, then select Add.
-
Use these values to configure the outbound rules:
Setting Value Name Enter myOutboundRule. Frontend IP address Select Create new.
In Name, enter LoadBalancerFrontEndOutbound.
Select IP address or IP prefix.
Select Create new under Public IP address or Public IP prefix.
For Name, enter myPublicIPOutbound or myPublicIPPrefixOutbound.
Select Add.Idle timeout (minutes) Move slider to 15 minutes. TCP Reset Select Enabled. Backend pool Select Create new.
Enter myBackendPoolOutbound in Name.
Select Add.Port allocation -> Port allocation Select Manually choose number of outbound ports Outbound ports -> Choose by Select Ports per instance Outbound ports -> Ports per instance Enter 10000. -
Select Add.
-
Select All services in the left-hand menu, select All resources, and then select myLoadBalancer from the resources list.
-
Under Settings, select Backend pools.
-
Select myBackendPoolOutbound.
-
In Virtual network, select myVNet.
-
In Virtual machines, select + Add.
-
Check the boxes next to myVM1, myVM2, and myVM3.
-
Select Add.
-
Select Save.
Note
Standard SKU load balancer is recommended for production workloads. For more information about SKUs, see Azure Load Balancer SKUs.
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.
-
On the top left-hand side of the screen, select Create a resource > Networking > Load Balancer.
-
In the Basics tab of the Create load balancer page, enter, or select the following information:
Setting Value Subscription Select your subscription. Resource group Select Create new and type myResourceGroupLB in the text box. Name Enter myLoadBalancer Region Select West Europe. Type Select Public. SKU Select Basic Public IP address Select Create new. If you have an existing Public IP you would like to use, select Use existing. Public IP address name Type myPublicIP in the text box. Assignment Select Dynamic Add a public IPv6 address Select No.
For more information on IPv6 addresses and load balancer, see What is IPv6 for Azure Virtual Network? -
Accept the defaults for the remaining settings, and then select Review + create.
-
In the Review + create tab, select Create.
:::image type="content" source="./media/quickstart-load-balancer-standard-public-portal/create-basic-load-balancer.png" alt-text="Create a basic load balancer" border="true":::
In this section, you configure:
- Create a virtual network.
- Load balancer settings for a backend address pool.
- A health probe.
- A load balancer rule.
In this section, you'll create a virtual network and subnet.
-
On the upper-left side of the screen, select Create a resource > Networking > Virtual network or search for Virtual network in the search box.
-
In Create virtual network, enter or select this information in the Basics tab:
Setting Value Project Details Subscription Select your Azure subscription Resource Group Select myResourceGroupLB Instance details Name Enter myVNet Region Select West Europe -
Select the IP Addresses tab or select 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 -
Under Subnet name, select the word default.
-
In Edit subnet, enter this information:
Setting Value Subnet name Enter myBackendSubnet Subnet address range Enter 10.1.0.0/24 -
Select Save.
-
Select the Security tab.
-
Under BastionHost, select Enable. Enter this information:
Setting Value Bastion name Enter myBastionHost AzureBastionSubnet address space Enter 10.1.1.0/24 Public IP Address Select Create new.
For Name, enter myBastionIP.
Select OK. -
Select the Review + create tab or select the Review + create button.
-
Select Create.
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.
-
Select All services in the left-hand menu, select All resources, and then select myLoadBalancer from the resources list.
-
Under Settings, select Backend pools, then select Add.
-
In the Add a backend pool page, enter, or select:
Setting Value Name Enter myBackendPool. Virtual network Select myVNet. Associated to Select Virtual machines
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.
-
Select All services in the left-hand menu, select All resources, and then select myLoadBalancer from the resources list.
-
Under Settings, select Health probes, then select Add.
Setting Value Name Enter myHealthProbe. Protocol Select HTTP. Port Enter 80. Path Enter / Interval Enter 15 for number of Interval in seconds between probe attempts. Unhealthy threshold Select 2 for number of Unhealthy threshold or consecutive probe failures that must occur before a VM is considered unhealthy. -
Select OK.
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.
-
Select All services in the left-hand menu, select All resources, and then select myLoadBalancer from the resources list.
-
Under Settings, select Load balancing rules, then select Add.
-
Use these values to configure the load-balancing rule:
Setting Value Name Enter myHTTPRule. IP Version Select IPv4 Frontend IP address Select LoadBalancerFrontEnd Protocol Select TCP. Port Enter 80. Backend port Enter 80. Backend pool Select myBackendPool. Health probe Select myHealthProbe. -
Leave the rest of the defaults and then select OK.
In this section, you:
- Create three virtual machines for the backend pool of the load balancer.
- Create an availability set for the virtual machines.
- Install IIS on the virtual machines to test the load balancer.
In this section, you'll create three VMs (myVM1, myVM2, and myVM3) with a basic public IP address.
The three VMs will be added to an availability set named myAvailabilitySet.
These VMs are added to the backend pool of the load balancer that was created earlier.
-
On the upper-left side of the portal, select Create a resource > Compute > Virtual machine.
-
In Create a virtual machine, type or select the values in the Basics tab:
Setting Value Project Details Subscription Select your Azure subscription Resource Group Select myResourceGroupLB Instance details Virtual machine name Enter myVM1 Region Select West Europe Availability Options Select Availability set Availability set Select Create new.
Enter myAvailabilitySet in Name.
Select OKImage Windows Server 2019 Datacenter Azure Spot instance Select No Size Choose VM size or take default setting Administrator account Username Enter a username Password Enter a password Confirm password Reenter password -
Select the Networking tab, or select Next: Disks, then Next: Networking.
-
In the Networking tab, select or enter:
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 the Create network security group, enter myNSG in Name.
Under Inbound rules, select +Add an inbound rule.
Under Destination port ranges, enter 80.
Under Priority, enter 100.
In Name, enter myHTTPRule
Select Add
Select OKLoad balancing Place this virtual machine behind an existing load balancing solution? Select No -
Select the Management tab, or select Next > Management.
-
In the Management tab, select or enter:
Setting Value Monitoring Boot diagnostics Select Off -
Select Review + create.
-
Review the settings, and then select Create.
-
Follow the steps 1 to 8 to create two additional VMs with the following values and all the other settings the same as myVM1:
Setting VM 2 VM 3 Name myVM2 myVM3 Availability set Select myAvailabilitySet Select myAvailabilitySet Network security group Select the existing myNSG Select the existing myNSG
The VMs created in the previous steps must be added to the backend pool of myLoadBalancer.
-
Select All services in the left-hand menu, select All resources, and then select myLoadBalancer from the resources list.
-
Under Settings, select Backend pools, then select myBackendPool.
-
Select Virtual machines in Associated to.
-
In the Virtual machines section, select + Add.
-
Select the boxes next to myVM1, myVM2, and myVM3.
-
Select Add.
-
Select Save.
-
Select All services in the left-hand menu, select All resources, and then from the resources list, select myVM1 that is located in the myResourceGroupLB resource group.
-
On the Overview page, select Connect, then Bastion.
-
Enter the username and password entered during VM creation.
-
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 to 6 to install IIS and the updated iisstart.htm file on myVM2 and myVM3.
-
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.
-
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.
When no longer needed, delete the resource group, load Balancer, and all related resources. To do so, select the resource group myResourceGroupLB that contains the resources and then select Delete.
In this quickstart, you:
- Created an Azure Standard or Basic Load Balancer
- Attached 3 VMs to the load balancer.
- Configured the load balancer traffic rule, health probe, and then tested the load balancer.
To learn more about Azure Load Balancer, continue to What is Azure Load Balancer? and Load Balancer frequently asked questions.
Learn more about Load Balancer and Availability zones.