Ensure that the upgrade policy is set to automatic.
If manual upgrade policy is used, upgrade all virtual machine instances after attaching it to the load balancer.
An existing standard SKU load balancer in the same subscription and virtual network as the Virtual Machine Scale Sets.
The load balancer must also have a backend pool with health probes and load balancing rules attached.
Access to the Azure portal CLI
Note
If you choose to use Azure CLI, you have can run AZ CLI in Azure Cloud Shell or as a local install. Review the following to ensure you are ready to use Azure CLI in the environment you choose.
If you prefer to run CLI reference commands locally, install the Azure CLI. If you're running on Windows or macOS, consider running Azure CLI in a Docker container. For more information, see How to run the Azure CLI in a Docker container.
If you're using a local installation, sign in to the Azure CLI by using the az sign-in command. To finish the authentication process, follow the steps displayed in your terminal. For other sign-in options, see Sign in with the Azure CLI.
When you're prompted, install the Azure CLI extension on first use. For more information about extensions, see Use extensions with the Azure CLI.
Run az version to find the version and dependent libraries that are installed. To upgrade to the latest version, run az upgrade.
Add Virtual Machine Scale Set to an Azure Load Balancer’s backend pool
In this section, you’ll learn how to attach your Virtual Machine Scale Sets behind a single Azure Load Balancer.
Note
The following section assumes a virtual network named myVnet and an Azure Load Balancer named myLoadBalancer has been previously deployed. In addition, the following section assumes the backend pools are NIC based.
In the search box at the top of the portal, enter Load balancer. Select Load balancers in the search results.
Select your balancer from the list.
In your load balancer's page, select Backend pools under Settings.
Select your backend pool.
In your backend pool's page, select + Add under IP configurations
Select the two Virtual Machine Scale Sets that you want to add to the backend pool.
Select Add and Save.
Connect to your Azure subscription with Azure CLI.
Add the first Virtual Machine Scale Set to a load balancer with az vmss update, and replace the values in brackets with the names of the resources in your configuration.
az vmss update\
--resource-group <resource-group> \
--name <vmss-name> \
--add virtualMachineProfile.networkProfile.networkInterfaceConfigurations[0].ipConfigurations[0].loadBalancerBackendAddressPools "{'id':'/subscriptions/<SubscriptionID>/resourceGroups/<Resource Group> /providers/Microsoft.Network/loadBalancers/<Load Balancer Name>/backendAddressPools/<Backend address pool name >'}"
This example deploys a Virtual Machine Scale Set with the following defined values: