Create a public Basic Load Balancer to load balance VMs using the Azure portal

Load balancing provides a higher level of availability and scale by spreading incoming requests across multiple virtual machines. You can use the Azure portal to create a load balancer to load balance virtual machines. This quickstart shows you how to create network resources, backend servers, and a public Basic Load Balancer.

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

Sign in to the Azure portal

Sign in to the Azure portal at http://portal.azure.com.

Create a Basic Load Balancer

In this section, you create a public Basic Load Balancer using the portal. The public IP address is automatically configured as the Load Balancer's frontend, named, LoadBalancerFrontend when you create the public IP when you create the load balancer resource using the portal.

  1. On the top left-hand side of the screen, click Create a resource > Networking > Load Balancer.
  2. In the Create a load balancer page enter these values for the load balancer:
    • myLoadBalancer - for the name of the load balancer.
    • Public - for the type of the load balancer.
    • myPublicIP - for the Public IP that you must create with SKU as Basic, and Assignment set as Dynamic.
    • myResourceGroupLB - for the name of the new resource group that you create.
  3. Click Create to create the load balancer.

    Create a load balancer

Create backend servers

In this section, you create a virtual network, create two virtual machines for the backend pool of your Basic Load Balancer, and then install IIS on the virtual machines to help test the load balancer.

Create a virtual network

  1. On the top left-hand side of the screen click New > Networking > Virtual network and enter these values for the virtual network:
    • myVnet - for the name of the virtual network.
    • myResourceGroupLB - for the name of the existing resource group
    • myBackendSubnet - for the subnet name.
  2. Click Create to create the virtual network.

    Create a virtual network

Create virtual machines

  1. On the top left-hand side of the screen, click New > Compute > Windows Server 2016 Datacenter and enter these values for the virtual machine:
    • myVM1 - for the name of the virtual machine.
    • azureuser - for the administrator user name. -
    • myResourceGroupLB - for Resource group, select Use existing, and then select myResourceGroupLB.
  2. Click OK.
  3. Select DS1_V2 for the size of the virtual machine, and click Select.
  4. Enter these values for the VM settings:
    • myAvailabilitySet - for the name of the new Availability set that you create.
    • myVNet - ensure it is selected as the virtual network.
    • myBackendSubnet - ensure it is selected as the subnet.
    • myVM1-ip - for Public IP address.
    • myNetworkSecurityGroup - for the name of the new network security group (firewall) that you must create.
  5. Click Disabled to disable boot diagnostics.
  6. Click OK, review the settings on the summary page, and then click Create.
  7. Using steps 1-6, create a second VM, named, VM2 with myAvailabilityset as the Availability set, myVnet as the virtual network, myBackendSubnet as subnet, and myNetworkSecurityGroup as its Network Security Group, .

Create NSG rules

In this section, you create NSG rules to allow inbound connections using HTTP and RDP.

  1. Click All resources in the left-hand menu, and then from the resources list click myNetworkSecurityGroup that is located in the myResourceGroupLB resource group.
  2. Under Settings, click Inbound security rules, and then click Add.
  3. Enter these values for the inbound security rule named myHTTPRule to allow for an inbound HTTP connections using port 80:
    • Service Tag - for Source.
    • Internet - for Source service tag
    • 80 - for Destination port ranges
    • TCP - for Protocol
    • Allow - for Action
    • 100 for Priority
    • myHTTPRule for name
    • Allow HTTP - for description
  4. Click OK.

    Create a virtual network

  5. Repeat steps 2 to 4 to create another rule named myRDPRule to allow for an inbound RDP connection using port 3389 with the following values:
    • Service Tag - for Source.
    • Internet - for Source service tag
    • 3389 - for Destination port ranges
    • TCP - for Protocol
    • Allow - for Action
    • 200 for Priority
    • myRDPRule for name
    • Allow RDP - for description

Install IIS

  1. Click All resources in the left-hand menu, and then from the resources list click myVM1 that is located in the myResourceGroupLB resource group.
  2. On the Overview page, click Connect to RDP into the VM.
  3. Log into the VM with username azureuser and password Azure123456!
  4. On the server desktop, navigate to Windows Administrative Tools>Server Manager.
  5. In Server Manager, click Manage, and then, click Add Roles and features. Adding server manager role
  6. In the Add Roles and Features Wizard, use the following values:
    • In the Select installation type page, click Role-based or feature-based installation.
    • In the Select destination server page, click myVM1
    • In the Select server role page, click Web Server (IIS)
    • Follow instructions to complete the rest of the wizard
  7. Repeat steps 1 to 6 for the virtual machine myVM2.

Create Basic Load Balancer resources

In this section, you configure load balancer settings for a backend address pool and a health probe, and specify load balancer and NAT rules.

Create a backend address pool

To distribute traffic to the VMs, a back-end address pool contains the IP addresses of the virtual (NICs) connected to the load balancer. Create the backend address pool myBackendPool to include VM1 and VM2.

  1. Click All resources in the left-hand menu, and then click myLoadBalancer from the resources list.
  2. Under Settings, click Backend pools, then click Add.
  3. On the Add a backend pool page, do the following:

    • For name, type *myBackEndPool, as the name for your backend pool.
    • For Associated to, from the drop-down menu, click Availability set
    • For Availability set, click, myAvailabilitySet.
    • Click Add a target network IP configuration to add each virtual machine (myVM1 & myVM2) that you created to the backend pool.
    • Click OK.

      Adding to the backend address pool -

  4. Check to make sure your load balancer backend pool setting displays both the VMs VM1 and VM2.

Create a health probe

To allow the Basic Load Balancer to monitor the status of your app, 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. Create a health probe myHealthProbe to monitor the health of the VMs.

  1. Click All resources in the left-hand menu, and then click myLoadBalancer from the resources list.
  2. Under Settings, click Health probes, then click Add.
  3. Use these values to create the health probe:
    • myHealthProbe - for the name of the health probe.
    • HTTP - for the protocol type.
    • 80 - for the port number.
    • 15 - for number of Interval in seconds between probe attempts.
    • 2 - for number of Unhealthy threshold or consecutive probe failures that must occur before a VM is considered unhealthy.
  4. Click OK.

    Adding a probe

Create a Load Balancer rule

A Load Balancer rule is used to define how traffic is distributed to the VMs. You define the front-end IP configuration for the incoming traffic and the back-end IP pool to receive the traffic, along with the required source and destination port. Create a Load Balancer rule myLoadBalancerRuleWeb for listening to port 80 in the frontend LoadBalancerFrontEnd and sending load-balanced network traffic to the backend address pool myBackEndPool also using port 80.

  1. Click All resources in the left-hand menu, and then click myLoadBalancer from the resources list.
  2. Under Settings, click Load balancing rules, then click Add.
  3. Use these values to configure the load balancing rule:
    • myHTTPRule - for the name of the load balancing rule.
    • TCP - for the protocol type.
    • 80 - for the port number.
    • 80 - for the backend port.
    • myBackendPool - for the name of the backend pool.
    • myHealthProbe - for the name of the health probe.
  4. Click OK.

    Adding a load balancing rule

Test the load balancer

  1. Find the public IP address for the Load Balancer on the Overview screen. Click All resources and then click 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.

    IIS Web server

Clean up resources

When no longer needed, delete the resource group, load balancer, and all related resources. To do so, select the resource group that contains the load balancer and click Delete.

Next steps

In this quickstart, you created a resource group, network resources, and backend servers. You then used those resources to create a load balancer. To learn more about load balancers and their associated resources, continue to the tutorial articles.