title | titleSuffix | description | services | author | ms.service | ms.topic | ms.date | ms.author |
---|---|---|---|---|---|---|---|---|
Backend Pool Management |
Azure Load Balancer |
Get started learning how to configure and manage the backend pool of an Azure Load Balancer |
load-balancer |
asudbring |
load-balancer |
how-to |
07/07/2020 |
allensu |
The backend pool is a critical component of the load balancer. The backend pool defines the group of resources that will serve traffic for a given load-balancing rule.
There are two ways of configuring a backend pool:
- Network Interface Card (NIC)
- Combination of IP address and Virtual Network (VNET) Resource ID
Configure your backend pool by NIC when using existing virtual machines and virtual machine scale sets. This method builds the most direct link between your resource and the backend pool.
When preallocating your backend pool with an IP address range which you plan to later create virtual machines and virtual machine scale sets, configure your backend pool by IP address and VNET ID combination.
The configuration sections of this article will focus on:
- Azure PowerShell
- Azure CLI
- REST API
- Azure Resource Manager templates
These sections give insight into how the backend pools are structured for each configuration option.
The backend pool is created as part of the load balancer operation. The IP configuration property of the NIC is used to add backend pool members.
The following examples are focused on the create and populate operations for the backend pool to highlight this workflow and relationship.
Note
It is important to note that backend pools configured via network interface cannot be updated as part of an operation on the backend pool. Any addition or deletion of backend resources must occur on the network interface of the resource.
Create a new backend pool:
$resourceGroup = "myResourceGroup"
$loadBalancerName = "myLoadBalancer"
$backendPoolName = "myBackendPool"
$backendPool =
New-AzLoadBalancerBackendAddressPool -ResourceGroupName $resourceGroup -LoadBalancerName $loadBalancerName -BackendAddressPoolName $backendPoolName
Create a new network interface and add it to the backend pool:
$resourceGroup = "myResourceGroup"
$loadBalancerName = "myLoadBalancer"
$backendPoolName = "myBackendPool"
$nicname = "myNic"
$location = "eastus"
$vnetname = <your-vnet-name>
$vnet =
Get-AzVirtualNetwork -Name $vnetname -ResourceGroupName $resourceGroup
$nic =
New-AzNetworkInterface -ResourceGroupName $resourceGroup -Location $location -Name $nicname -LoadBalancerBackendAddressPool $backendPoolName -Subnet $vnet.Subnets[0]
Retrieve the backend pool information for the load balancer to confirm that this network interface is added to the backend pool:
$resourceGroup = "myResourceGroup"
$loadBalancerName = "myLoadBalancer"
$backendPoolName = "myBackendPool"
$lb =
Get-AzLoadBalancer -ResourceGroupName $res
Get-AzLoadBalancerBackendAddressPool -ResourceGroupName $resourceGroup -LoadBalancerName $loadBalancerName -BackendAddressPoolName $backendPoolName
Create a new virtual machine and attach the network interface to place it in the backend pool:
# Create a username and password for the virtual machine
$cred = Get-Credential
# Create a virtual machine configuration
$vmname = "myVM1"
$vmsize = "Standard_DS1_v2"
$pubname = "MicrosoftWindowsServer"
$nicname = "myNic"
$off = "WindowsServer"
$sku = "2019-Datacenter"
$resourceGroup = "myResourceGroup"
$location = "eastus"
$nic =
Get-AzNetworkInterface -Name $nicname -ResourceGroupName $resourceGroup
$vmConfig =
New-AzVMConfig -VMName $vmname -VMSize $vmsize | Set-AzVMOperatingSystem -Windows -ComputerName $vmname -Credential $cred | Set-AzVMSourceImage -PublisherName $pubname -Offer $off -Skus $sku -Version latest | Add-AzVMNetworkInterface -Id $nic.Id
# Create a virtual machine using the configuration
$vm1 = New-AzVM -ResourceGroupName $resourceGroup -Zone 1 -Location $location -VM $vmConfig
Create the backend pool:
az network lb address-pool create \
--resourceGroup myResourceGroup \
--lb-name myLB \
--name myBackendPool
Create a new network interface and add it to the backend pool:
az network nic create \
--resource-group myResourceGroup \
--name myNic \
--vnet-name myVnet \
--subnet mySubnet \
--network-security-group myNetworkSecurityGroup \
--lb-name myLB \
--lb-address-pools myBackEndPool
Retrieve the backend pool to confirm the IP address have been correctly added:
az network lb address-pool show \
--resource-group myResourceGroup \
--lb-name myLb \
--name myBackendPool
Create a new virtual machine and attach the network interface to place it in the backend pool:
az vm create \
--resource-group myResourceGroup \
--name myVM \
--nics myNic \
--image UbuntuLTS \
--admin-username azureuser \
--generate-ssh-keys
Create the backend pool:
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/loadBalancers/{load-balancer-name}/backendAddressPools/{backend-pool-name}?api-version=2020-05-01
Create a network interface and add it to the backend pool you've created via the IP configurations property of the network interface:
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/networkInterfaces/{nic-name}?api-version=2020-05-01
JSON request body:
{
"properties": {
"enableAcceleratedNetworking": true,
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/virtualNetworks/{vnet-name}/subnets/{subnet-name}"
},
"loadBalancerBackendAddressPools": {
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/loadBalancers/{load-balancer-name}/backendAddressPools/{backend-pool-name}"
}
}
}
]
},
"location": "eastus"
}
Retrieve the backend pool information for the load balancer to confirm that this network interface is added to the backend pool:
GET https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name/providers/Microsoft.Network/loadBalancers/{load-balancer-name/backendAddressPools/{backend-pool-name}?api-version=2020-05-01
Create a VM and attach the NIC referencing the backend pool:
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}?api-version=2019-12-01
JSON request body:
{
"location": "easttus",
"properties": {
"hardwareProfile": {
"vmSize": "Standard_D1_v2"
},
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"name": "myVMosdisk",
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{nic-name}",
"properties": {
"primary": true
}
}
]
},
"osProfile": {
"adminUsername": "{your-username}",
"computerName": "myVM",
"adminPassword": "{your-password}"
}
}
}
Follow this quickstart Resource Manager template to deploy a load balancer and virtual machines and add the virtual machines to the backend pool via network interface.
In scenarios with pre-populated backend pools, use IP and virtual network.
All backend pool management is done directly on the backend pool object as highlighted in the examples below.
Important
This feature is currently in preview and has the following limitations:
- Standard load balancer only
- Limit of 100 IP addresses in the backend pool
- The backend resources must be in the same virtual network as the load balancer
- This feature is not currently supported in the Azure portal
- ACI containers are not currently supported by this feature
- Load balancers or services fronted by load balancers cannot be placed in the backend pool of the load balancer
Create new backend pool:
$resourceGroup = "myResourceGroup"
$loadBalancerName = "myLoadBalancer"
$backendPoolName = "myBackendPool"
$vnetName = "myVnet"
$location = "eastus"
$nicName = "myNic"
$backendPool = New-AzLoadBalancerBackendAddressPool -ResourceGroupName $resourceGroup -LoadBalancerName $loadBalancerName -Name $backendPoolName
Update backend pool with a new IP from existing virtual network:
$virtualNetwork =
Get-AzVirtualNetwork -Name $vnetName -ResourceGroupName $resourceGroup
$ip1 = New-AzLoadBalancerBackendAddressConfig -IpAddress "10.0.0.5" -Name "TestVNetRef" -VirtualNetwork $virtualNetwork
$backendPool.LoadBalancerBackendAddresses.Add($ip1)
Set-AzLoadBalancerBackendAddressPool -InputObject $backendPool
Retrieve the backend pool information for the load balancer to confirm that the backend addresses are added to the backend pool:
Get-AzLoadBalancerBackendAddressPool -ResourceGroupName $resourceGroup -LoadBalancerName $loadBalancerName -Name $backendPoolName
Create a network interface and add it to the backend pool. Set the IP address to one of the backend addresses:
$nic =
New-AzNetworkInterface -ResourceGroupName $resourceGroup -Location $location -Name $nicName -PrivateIpAddress 10.0.0.4 -Subnet $virtualNetwork.Subnets[0]
Create a VM and attach the NIC with an IP address in the backend pool:
# Create a username and password for the virtual machine
$cred = Get-Credential
# Create a virtual machine configuration
$vmname = "myVM1"
$vmsize = "Standard_DS1_v2"
$pubname = "MicrosoftWindowsServer"
$nicname = "myNic"
$off = "WindowsServer"
$sku = "2019-Datacenter"
$resourceGroup = "myResourceGroup"
$location = "eastus"
$nic =
Get-AzNetworkInterface -Name $nicname -ResourceGroupName $resourceGroup
$vmConfig =
New-AzVMConfig -VMName $vmname -VMSize $vmsize | Set-AzVMOperatingSystem -Windows -ComputerName $vmname -Credential $cred | Set-AzVMSourceImage -PublisherName $pubname -Offer $off -Skus $sku -Version latest | Add-AzVMNetworkInterface -Id $nic.Id
# Create a virtual machine using the configuration
$vm1 = New-AzVM -ResourceGroupName $resourceGroup -Zone 1 -Location $location -VM $vmConfig
Using CLI you can either populate the backend pool via command-line parameters or through a JSON configuration file.
Create and populate the backend pool via the command-line parameters:
az network lb address-pool create \
--resource-group myResourceGroup \
--lb-name myLB \
--name myBackendPool \
--vnet {VNET resource ID} \
--backend-address name=addr1 ip-address=10.0.0.4 \
--backend-address name=addr2 ip-address=10.0.0.5
Create and populate the Backend Pool via JSON configuration file:
az network lb address-pool create \
--resource-group myResourceGroup \
--lb-name myLB \
--name myBackendPool \
--vnet {VNET resource ID} \
--backend-address-config-file @config_file.json
JSON configuration file:
[
{
"name": "address1",
"virtualNetwork": "/subscriptions/{subscriptionId}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/virtualNetworks/{vnet-name}",
"ipAddress": "10.0.0.4"
},
{
"name": "address2",
"virtualNetwork": "/subscriptions/{subscriptionId}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/virtualNetworks/{vnet-name}",
"ipAddress": "10.0.0.5"
}
]
Retrieve the backend pool information for the load balancer to confirm that the backend addresses are added to the backend pool:
az network lb address-pool show \
--resource-group myResourceGroup \
--lb-name MyLb \
--name MyBackendPool
Create a network interface and add it to the backend pool. Set the IP address to one of the backend addresses:
az network nic create \
--resource-group myResourceGroup \
--name myNic \
--vnet-name myVnet \
--subnet mySubnet \
--network-security-group myNetworkSecurityGroup \
--lb-name myLB \
--private-ip-address 10.0.0.4
Create a VM and attach the NIC with an IP address in the backend pool:
az vm create \
--resource-group myResourceGroup \
--name myVM \
--nics myNic \
--image UbuntuLTS \
--admin-username azureuser \
--generate-ssh-keys
Create the backend pool and define the backend addresses via a PUT backend pool request. Configure the backend addresses in the JSON body of the PUT request by:
- Address name
- IP address
- Virtual network ID
PUT https://management.azure.com/subscriptions/subid/resourceGroups/testrg/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/backend?api-version=2020-05-01
JSON Request Body:
{
"properties": {
"loadBalancerBackendAddresses": [
{
"name": "address1",
"properties": {
"virtualNetwork": {
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/virtualNetworks/{vnet-name}"
},
"ipAddress": "10.0.0.4"
}
},
{
"name": "address2",
"properties": {
"virtualNetwork": {
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/virtualNetworks/{vnet-name}"
},
"ipAddress": "10.0.0.5"
}
}
]
}
}
Retrieve the backend pool information for the load balancer to confirm that the backend addresses are added to the backend pool:
GET https://management.azure.com/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/loadBalancers/{load-balancer-name}/backendAddressPools/{backend-pool-name}?api-version=2020-05-01
Create a network interface and add it to the backend pool. Set the IP address to one of the backend addresses:
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/networkInterfaces/{nic-name}?api-version=2020-05-01
JSON Request Body:
{
"properties": {
"enableAcceleratedNetworking": true,
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAddress": "10.0.0.4",
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/virtualNetworks/{vnet-name}/subnets/{subnet-name}"
}
}
}
]
},
"location": "eastus"
}
Create a VM and attach the NIC with an IP address in the backend pool:
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}?api-version=2019-12-01
JSON Request Body:
{
"location": "eastus",
"properties": {
"hardwareProfile": {
"vmSize": "Standard_D1_v2"
},
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"name": "myVMosdisk",
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{nic-name}",
"properties": {
"primary": true
}
}
]
},
"osProfile": {
"adminUsername": "{your-username}",
"computerName": "myVM",
"adminPassword": "{your-password}"
}
}
}
Create the load balancer, backend pool, and populate the backend pool with backend addresses:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"loadBalancers_myLB_location": {
"type": "SecureString"
},
"loadBalancers_myLB_location_1": {
"type": "SecureString"
},
"backendAddressPools_myBackendPool_location": {
"type": "SecureString"
},
"backendAddressPools_myBackendPool_location_1": {
"type": "SecureString"
},
"loadBalancers_myLB_name": {
"defaultValue": "myLB",
"type": "String"
},
"virtualNetworks_myVNET_externalid": {
"defaultValue": "/subscriptions/6bb4a28a-db84-4e8a-b1dc-fabf7bd9f0b2/resourceGroups/ErRobin4/providers/Microsoft.Network/virtualNetworks/myVNET",
"type": "String"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Network/loadBalancers",
"apiVersion": "2020-04-01",
"name": "[parameters('loadBalancers_myLB_name')]",
"location": "eastus",
"sku": {
"name": "Standard"
},
"properties": {
"frontendIPConfigurations": [
{
"name": "LoadBalancerFrontEnd",
"properties": {
"privateIPAddress": "10.0.0.7",
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[concat(parameters('virtualNetworks_myVNET_externalid'), '/subnets/Subnet-1')]"
},
"privateIPAddressVersion": "IPv4"
}
}
],
"backendAddressPools": [
{
"name": "myBackendPool",
"properties": {
"loadBalancerBackendAddresses": [
{
"name": "addr1",
"properties": {
"ipAddress": "10.0.0.4",
"virtualNetwork": {
"location": "[parameters('loadBalancers_myLB_location')]"
}
}
},
{
"name": "addr2",
"properties": {
"ipAddress": "10.0.0.5",
"virtualNetwork": {
"location": "[parameters('loadBalancers_myLB_location_1')]"
}
}
}
]
}
}
],
"loadBalancingRules": [],
"probes": [],
"inboundNatRules": [],
"outboundRules": [],
"inboundNatPools": []
}
},
{
"type": "Microsoft.Network/loadBalancers/backendAddressPools",
"apiVersion": "2020-04-01",
"name": "[concat(parameters('loadBalancers_myLB_name'), '/myBackendPool')]",
"dependsOn": [
"[resourceId('Microsoft.Network/loadBalancers', parameters('loadBalancers_myLB_name'))]"
],
"properties": {
"loadBalancerBackendAddresses": [
{
"name": "addr1",
"properties": {
"ipAddress": "10.0.0.4",
"virtualNetwork": {
"location": "[parameters('backendAddressPools_myBackendPool_location')]"
}
}
},
{
"name": "addr2",
"properties": {
"ipAddress": "10.0.0.5",
"virtualNetwork": {
"location": "[parameters('backendAddressPools_myBackendPool_location_1')]"
}
}
}
]
}
}
]
}
Create a virtual machine and attached network interface. Set the IP address of the network interface to the one of the backend addresses:
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountName": {
"type": "String",
"metadata": {
"description": "Name of storage account"
}
},
"storageAccountDomain": {
"type": "String",
"metadata": {
"description": "The domain of the storage account to be created."
}
},
"adminUsername": {
"type": "String",
"metadata": {
"description": "Admin username"
}
},
"adminPassword": {
"type": "SecureString",
"metadata": {
"description": "Admin password"
}
},
"vmName": {
"defaultValue": "myVM",
"type": "String",
"metadata": {
"description": "Prefix to use for VM names"
}
},
"imagePublisher": {
"type": "String",
"metadata": {
"description": "Image Publisher"
}
},
"imageOffer": {
"defaultValue": "WindowsServer",
"type": "String",
"metadata": {
"description": "Image Offer"
}
},
"imageSKU": {
"defaultValue": "2012-R2-Datacenter",
"type": "String",
"metadata": {
"description": "Image SKU"
}
},
"lbName": {
"defaultValue": "myLB",
"type": "String",
"metadata": {
"description": "Load Balancer name"
}
},
"nicName": {
"defaultValue": "nic",
"type": "String",
"metadata": {
"description": "Network Interface name prefix"
}
},
"privateIpAddress": {
"defaultValue": "10.0.0.5",
"type": "String",
"metadata": {
"description": "Private IP Address of the VM"
}
},
"vnetName": {
"defaultValue": "myVNET",
"type": "String",
"metadata": {
"description": "VNET name"
}
},
"vmSize": {
"defaultValue": "Standard_A1",
"type": "String",
"metadata": {
"description": "Size of the VM"
}
},
"storageLocation": {
"type": "String",
"metadata": {
"description": "Location of the Storage Account."
}
},
"location": {
"type": "String",
"metadata": {
"description": "Location to deploy all the resources in."
}
}
},
"variables": {
"networkSecurityGroupName": "networkSecurityGroup1",
"storageAccountType": "Standard_LRS",
"subnetName": "Subnet-1",
"publicIPAddressType": "Static",
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks',parameters('vnetName'))]",
"subnetRef": "[concat(variables('vnetID'),'/subnets/',variables ('subnetName'))]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2015-05-01-preview",
"name": "[parameters('storageAccountName')]",
"location": "[parameters('storageLocation')]",
"properties": {
"accountType": "[variables('storageAccountType')]"
}
},
{
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2016-03-30",
"name": "[variables('networkSecurityGroupName')]",
"location": "[parameters('location')]",
"properties": {
"securityRules": []
}
},
{
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2015-05-01-preview",
"name": "[parameters('nicName')]",
"location": "[parameters('location')]",
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Static",
"privateIpAddress": "[parameters('privateIpAddress')]",
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
]
}
},
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2015-05-01-preview",
"name": "[parameters('vmName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]",
"[parameters('nicName')]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computername": "[parameters('vmName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"publisher": "[parameters('imagePublisher')]",
"offer": "[parameters('imageOffer')]",
"sku": "[parameters('imageSKU')]",
"version": "latest"
},
"osDisk": {
"name": "osdisk",
"vhd": {
"uri": "[concat('http://',parameters('storageAccountName'),'.blob.',parameters('storageAccountDomain'),'/vhds/','osdisk', '.vhd')]"
},
"caching": "ReadWrite",
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces',parameters('nicName'))]"
}
]
}
}
}
]
}
In this article, you learned about Azure Load Balancer backend pool management and how to configure a backend pool by IP address and virtual network.
Learn more about Azure Load Balancer.