Quickstart: Create a public Basic load balancer by using the Azure portal

Load balancing provides a higher level of availability and scale by spreading incoming requests across virtual machines (VMs). You can use the Azure portal to create a load balancer and balance traffic among VMs. This quickstart shows you how to create and configure a load balancer, back-end servers, and network resources at the Basic pricing tier.

If you don't have an Azure subscription, create a free account before you begin.

To do the tasks in this quickstart, sign in to the Azure portal.

Create a Basic load balancer

First, create a public Basic load balancer by using the portal. The name and public IP address you create are automatically configured as the load balancer's front end.

  1. On the upper-left side of the portal, select Create a resource > Networking > Load Balancer.

  2. In the Create load balancer pane, type or select these values:

    • Name: Type MyLoadBalancer.
    • Type: Select Public.
    • SKU: Select Basic.
    • Public IP address: Select Create new.
      • Public IP Address field: Type MyPublicIP.
      • Configure Public IP address > Assignment: Select Dynamic.
    • ResourceGroup: Select Create new, then enter MyResourceGroupLB, and select OK.
  3. Select Create.

Create a load balancer

Create back-end servers

Next, create a virtual network and two virtual machines for the back-end pool of your Basic load balancer.

Create a virtual network

  1. On the upper-left side of the portal, select Create a resource > Networking > Virtual network.

  2. In the Create virtual network pane, type or select these values:

    • Name: Type MyVnet.
    • ResourceGroup: Drop down Select existing and select MyResourceGroupLB.
    • Subnet > Name: Type MyBackendSubnet.
  3. Select Create.

    Create a virtual network

Create virtual machines

  1. On the upper-left side of the portal, select Create a resource > Compute > Windows Server 2016 Datacenter.

  2. In Create a virtual machine, type or select the following values in the Basics tab:

    • Subscription > Resource Group: Drop down and select MyResourceGroupLB.
    • Instance Details > Virtual machine name: Type MyVM1.
    • Instance Details > Availability Options:
      1. Drop down and select Availability set.
      2. Select Create new, type MyAvailabilitySet, and select OK.
  3. Select the Networking tab, or select Next: Disks, then Next: Networking.

    Make sure the following are selected:

    • Virtual network: MyVnet
    • Subnet: MyBackendSubnet
    • Public IP: MyVM1-ip

    To create a new network security group (NSG), a type of firewall, under Network Security Group, select Advanced.

    1. In the Configure network security group field, select Create new.
    2. Type MyNetworkSecurityGroup, and select OK.
  4. Select the Management tab, or select Next > Management. Under Monitoring, set Boot diagnostics to Off.

  5. Select Review + create.

  6. Review the settings, and then select Create.

  7. Follow the steps to create a second VM named MyVM2, with a Public IP address of MyVM2-ip, and all the other settings the same as MyVM1.

Create NSG rules for the VMs

In this section, you create network security group (NSG) rules for the VMs, to allow inbound internet (HTTP) and remote desktop (RDP) connections.

  1. Select All resources on the left menu. From the resource list, select MyNetworkSecurityGroup in the MyResourceGroupLB resource group.

  2. Under Settings, select Inbound security rules, and then select Add.

  3. In the Add inbound security rule dialog, for the HTTP rule, type or select the following:

    • Source: Select Service Tag.
    • Source service tag: Select Internet.
    • Destination port ranges: Type 80.
    • Protocol: Select TCP.
    • Action: Select Allow.
    • Priority: Type 100.
    • Name: Type MyHTTPRule.
    • Description: Type Allow HTTP.
  4. Select Add.

    Create an NSG rule

  5. Repeat the steps for the inbound RDP rule, with the following differing values:

    • Destination port ranges: Type 3389.
    • Priority: Type 200.
    • Name: Type MyRDPRule.
    • Description: Type Allow RDP.

Create resources for the load balancer

In this section, you configure load balancer settings for a back-end address pool, a health probe, and a load balancer rule.

Create a backend address pool

To distribute traffic to the VMs, the load balancer uses a back-end address pool. The back-end address pool contains the IP addresses of the virtual network interfaces (NICs) that are connected to the load balancer.

To create a back-end address pool that includes VM1 and VM2:

  1. Select All resources on the left menu, and then select MyLoadBalancer from the resource list.

  2. Under Settings, select Backend pools, and then select Add.

  3. On the Add a backend pool page, type or select the following values:

    • Name: Type MyBackEndPool.
    • Associated to: Drop down and select Availability set.
    • Availability set: Select MyAvailabilitySet.
  4. Select Add a target network IP configuration.

    1. Add each virtual machine (MyVM1 and MyVM2) that you created to the back-end pool.
    2. After you add each machine, drop down and select its Network IP configuration.
  5. Select OK.

    Add the backend address pool

  6. On the Backend pools page, expand MyBackendPool and make sure both VM1 and VM2 are listed.

Create a health probe

To allow the load balancer to monitor VM status, you use a health probe. The health probe dynamically adds or removes VMs from the load balancer rotation based on their response to health checks.

To create a health probe to monitor the health of the VMs:

  1. Select All resources on the left menu, and then select MyLoadBalancer from the resource list.

  2. Under Settings, select Health probes, and then select Add.

  3. On the Add a health probe page, type or select the following values:

    • Name: Type MyHealthProbe.
    • Protocol: Drop down and select HTTP.
    • Port: Type 80.
    • Path: Accept / for the default URI. You can replace this value with any other URI.
    • Interval: Type 15. Interval is the number of seconds between probe attempts.
    • Unhealthy threshold: Type 2. This value is the number of consecutive probe failures that occur before a VM is considered unhealthy.
  4. Select OK.

    Add a probe

Create a load balancer rule

A load balancer rule defines how traffic is distributed to the VMs. The rule defines the front-end IP configuration for incoming traffic, the back-end IP pool to receive the traffic, and the required source and destination ports.

The load balancer rule named MyLoadBalancerRule listens to port 80 in the front-end LoadBalancerFrontEnd. The rule sends network traffic to the back-end address pool MyBackEndPool, also on port 80.

To create the load balancer rule:

  1. Select All resources on the left menu, and then select MyLoadBalancer from the resource list.

  2. Under Settings, select Load balancing rules, and then select Add.

  3. On the Add load balancing rule page, type or select the following values:

    • Name: Type MyLoadBalancerRule.
    • Frontend IP address: Type LoadBalancerFrontend.
    • Protocol: Select TCP.
    • Port: Type 80.
    • Backend port: Type 80.
    • Backend pool: Select MyBackendPool.
    • Health probe: Select MyHealthProbe.
  4. Select OK.

    Add a load balancer rule

Test the load balancer

You'll use the public IP address to test the load balancer on the VMs.

In the portal, on the Overview page for MyLoadBalancer, find its public IP address under Public IP Address. Hover over the address and select the Copy icon to copy it.

Install IIS on the VMs

Install Internet Information Services (IIS) on the virtual machines to help test the load balancer.

To remote desktop (RDP) into the VM:

  1. In the portal, select All resources on the left menu. From the resource list, select MyVM1 in the MyResourceGroupLB resource group.

  2. On the Overview page, select Connect, and then select Download RDP file.

  3. Open the RDP file you downloaded, and select Connect.

  4. On the Windows Security screen, select More choices and then Use a different account.

    Enter username and password and select OK.

  5. Respond Yes to any certificate prompt.

    The VM desktop opens in a new window.

To install IIS on the VM:

  1. If Server Manager is not already open on the server desktop, browse to Windows Administrative Tools > Server Manager.

  2. In Server Manager, select Add roles and features.

    Adding server manager role

  3. In the Add Roles and Features Wizard:

    1. On the Select installation type page, select Role-based or feature-based installation.
    2. On the Select destination server page, select MyVM1.
    3. On the Select server role page, select Web Server (IIS).
    4. At the prompt to install required tools, select Add Features.
    5. Accept the defaults, and select Install.
    6. When the features are finished installing, select Close.
  4. Repeat the steps for the virtual machine MyVM2, except set the destination server to MyVM2.

Test the load balancer

Open a browser and paste your load balancer's public IP address into the browser's address bar. The IIS web server default page should appear in the browser.

IIS web server

Clean up resources

To delete the load balancer and all related resources when you no longer need them, open the MyResourceGroupLB resource group and select Delete resource group.

Next steps

In this quickstart, you created a Basic-tier load balancer. You created and configured a resource group, network resources, back-end servers, a health probe, and rules to use with the load balancer. You installed IIS on the VMs and used it to test the load balancer.

To learn more about Azure Load Balancer, continue to the tutorials.