Creating a public load balancer using a template

An Azure load balancer is a Layer-4 (TCP, UDP) load balancer. The load balancer provides high availability by distributing incoming traffic among healthy service instances in cloud services or virtual machines in a load balancer set. Azure Load Balancer can also present those services on multiple ports, multiple IP addresses, or both.

You can configure a load balancer to:

  • Load balance incoming Internet traffic to virtual machines (VMs). We refer to a load balancer in this scenario as an Internet-facing load balancer.
  • Load balance traffic between VMs in a virtual network (VNet), between VMs in cloud services, or between on-premises computers and VMs in a cross-premises virtual network. We refer to a load balancer in this scenario as an internal load balancer (ILB).
  • Forward external traffic to a specific VM instance.

The following tasks will be done in this scenario:

  • Create a load balancer that receives network traffic on port 80 and send load-balanced traffic to virtual machines "web1" and "web2"
  • Create NAT rules for remote desktop access/SSH for virtual machines behind the load balancer
  • Create health probes

Load balancer scenario

Deploy the template by using click to deploy

The sample template available in the public repository uses a parameter file containing the default values used to generate the scenario described above. To deploy this template using click to deploy, follow this link, click Deploy to Azure, replace the default parameter values if necessary, and follow the instructions in the portal.

Deploy the template by using PowerShell

To deploy the template you downloaded by using PowerShell, follow the steps below.

  1. If you have never used Azure PowerShell, see How to Install and Configure Azure PowerShell and follow the instructions all the way to the end to sign into Azure and select your subscription.
  2. Run the New-AzureRmResourceGroupDeployment cmdlet to create a resource group using the template.

    New-AzureRmResourceGroupDeployment -Name TestRG -Location uswest `
        -TemplateFile '' `
        -TemplateParameterFile ''

Deploy the template by using the Azure CLI

To deploy the template by using the Azure CLI, follow the steps below.

  1. If you have never used Azure CLI, see Install and Configure the Azure CLI and follow the instructions up to the point where you select your Azure account and subscription.
  2. Run the azure config mode command to switch to Resource Manager mode, as shown below.

    azure config mode arm

    Here is the expected output for the command above:

     info:    New mode is arm
  3. From your browser, navigate to the Quickstart Template, copy the contents of the json file and paste into a new file in your computer. For this scenario, you would be copying the values below to a file named c:\lb\azuredeploy.parameters.json.

  4. Run the azure group deployment create cmdlet to deploy the new load balancer by using the template and parameter files you downloaded and modified above. The list shown after the output explains the parameters used.

    azure group create --name TestRG --location westus --template-file '' --parameters-file 'c:\lb\azuredeploy.parameters.json'

Next steps

Get started configuring an internal load balancer

Configure a load balancer distribution mode

Configure idle TCP timeout settings for your load balancer