Create an internal load balancer using a template

Note

This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure PowerShell.

Azure Internal Load Balancer (ILB) provides network load balancing between virtual machines that reside inside a cloud service or a virtual network with a regional scope.

For information about the use and configuration of virtual networks with a regional scope, see Regional virtual networks. Existing virtual networks that have been configured for an affinity group cannot use ILB.

Configuration scenario

In this scenario, we're creating an internal load balancer in a virtual network as shown in the following figure:

Internal load balancer scenario

The configuration for our scenario is as follows:

  • Two virtual machines named DB1 and DB2
  • Endpoints for the internal load balancer
  • An internal load balancer

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. Download the parameters file to your local disk.

  3. Edit the file and save it.

  4. Run the New-AzResourceGroupDeployment cmdlet to create a resource group using the template.

    New-AzResourceGroupDeployment -Name TestRG -Location westus `
        -TemplateFile 'https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/201-2-vms-internal-load-balancer/azuredeploy.json' `
        -TemplateParameterFile 'C:\temp\azuredeploy.parameters.json'
    

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. Open the parameter file, select its contents, and save it to a file in your computer. For this example, we saved the parameters file to parameters.json.

  4. Run the azure group deployment create command to deploy the new internal 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-uri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/201-2-vms-internal-load-balancer/azuredeploy.json --parameters-file parameters.json
    

Next steps

Configure a load balancer distribution mode using source IP affinity

Configure idle TCP timeout settings for your load balancer

For the JSON syntax and properties of a load balancer in a template, see Microsoft.Network/loadBalancers.