|
| 1 | +--- |
| 2 | +title: Add multiple Virtual Machine Scale Set instances behind one Azure Load Balancer |
| 3 | +description: learn how to configure multiple Virtual Machine Scale Set instances behind a single Azure load Balancer |
| 4 | +author: mbender-ms |
| 5 | +ms.author: mbender |
| 6 | +ms.service: load-balancer |
| 7 | +ms.topic: how-to |
| 8 | +ms.date: 12/15/2022 |
| 9 | +ms.custom: template-how-to |
| 10 | +--- |
| 11 | + |
| 12 | +# Add multiple Virtual Machine Scale Set instances behind one Azure Load Balancer |
| 13 | + |
| 14 | +In this article, you’ll learn how to configure multiple Virtual Machine Scale Set instances behind a single Azure Load Balancer. |
| 15 | + |
| 16 | +## Prerequisites |
| 17 | + |
| 18 | +# [Azure portal](#tab/azureportal) |
| 19 | + |
| 20 | +- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) |
| 21 | +- Two or more [Virtual Machine Scale Sets](../virtual-machine-scale-sets/quick-create-portal.md) |
| 22 | + - Ensure the upgrade policy is set to automatic. |
| 23 | + - If manual upgrade policy is used, upgrade all virtual machine instances after attaching it to the load balancer. |
| 24 | +- An existing [standard SKU load balancer](quickstart-load-balancer-standard-internal-portal.md) in the same subscription and virtual network as the Virtual Machine Scale Sets. |
| 25 | + - The load balancer must also have a backend pool with health probes and load balancing rules attached. |
| 26 | +- Access to the Azure portal |
| 27 | +# [Azure CLI](#tab/azurecli/) |
| 28 | + |
| 29 | +- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) |
| 30 | +- Two or more [Virtual Machine Scale Sets](../virtual-machine-scale-sets/quick-create-portal.md) |
| 31 | + - Unsure that the upgrade policy is set to automatic. |
| 32 | + - If manual upgrade policy is used, upgrade all virtual machine instances after attaching it to the load balancer. |
| 33 | +- An existing [standard SKU load balancer](quickstart-load-balancer-standard-internal-portal.md) in the same subscription and virtual network as the Virtual Machine Scale Sets. |
| 34 | + - The load balancer must also have a backend pool with health probes and load balancing rules attached. |
| 35 | +- Access to the Azure portal CLI |
| 36 | + |
| 37 | +> [!NOTE] |
| 38 | +> 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. |
| 39 | +
|
| 40 | +- Use the Bash environment in [Azure Cloud Shell](../cloud-shell/quickstart.md) |
| 41 | + [](https://shell.azure.com) |
| 42 | +- If you prefer to run CLI reference commands locally, [install](/cli/azure/install-azure-cli) 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](/cli/azure/run-azure-cli-docker). |
| 43 | + |
| 44 | + - If you're using a local installation, sign in to the Azure CLI by using the [az sign-in](/cli/azure/reference-index#az-login) 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](/cli/azure/authenticate-azure-cli). |
| 45 | + |
| 46 | + - When you're prompted, install the Azure CLI extension on first use. For more information about extensions, see [Use extensions with the Azure CLI](/cli/azure/azure-cli-extensions-overview). |
| 47 | + |
| 48 | + - Run [az version](/cli/azure/reference-index?#az-version) to find the version and dependent libraries that are installed. To upgrade to the latest version, run [az upgrade](/cli/azure/reference-index?#az-upgrade). |
| 49 | + |
| 50 | +--- |
| 51 | + |
| 52 | +## Add Virtual Machine Scale Set to an Azure Load Balancer’s backend pool |
| 53 | + |
| 54 | +In this section, you’ll learn how to attach your Virtual Machine Scale Sets behind a single Azure Load Balancer. |
| 55 | + |
| 56 | +> [!NOTE] |
| 57 | +> 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. |
| 58 | +
|
| 59 | +# [Azure portal](#tab/azureportal) |
| 60 | + |
| 61 | +1. Sign into the [Azure portal](https://portal.azure.com). |
| 62 | +1. In the search box at the top of the portal, enter **Load balancer**. Select **Load balancers** in the search results. |
| 63 | +1. Select your balancer from the list. |
| 64 | +1. In your load balancer's page, select **Backend pools** under **Settings**. |
| 65 | +1. Select your backend pool. |
| 66 | +1. In your backend pool's page, select **+ Add** under **IP configurations** |
| 67 | +1. Select the two Virtual Machine Scale Sets that you want to add to the backend pool. |
| 68 | +1. Select **Add** and **Save**. |
| 69 | + |
| 70 | +# [Azure CLI](#tab/azurecli/) |
| 71 | + |
| 72 | +1. Connect to your Azure subscription with Azure CLI. |
| 73 | +1. Add the first Virtual Machine Scale Set to a load balancer with [az vmss update](/cli/azure/vmss#az-vmss-update), and replace the values in brackets with the names of the resources in your configuration. |
| 74 | + |
| 75 | + ```azurecli |
| 76 | + |
| 77 | + az vmss update\ |
| 78 | + --resource-group <resource-group> \ |
| 79 | + --name <vmss-name> \ |
| 80 | + --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 >}" |
| 81 | + |
| 82 | + ``` |
| 83 | +This example deploys a Virtual Machine Scale Set with the following defined values: |
| 84 | +
|
| 85 | +- Virtual Machine Scale Set named *myVMSS* |
| 86 | +- Azure Load Balancer named *MyLB* |
| 87 | +- Load Balancer backend pool named *mybackend* |
| 88 | +- Resource group named *myResourceGroup* |
| 89 | +- Subscription ID named *SubscriptionID* |
| 90 | +```azurecli |
| 91 | +
|
| 92 | +az vmss update \ |
| 93 | + --resource-group myResourceGroup \ |
| 94 | + --name myVMSS \ |
| 95 | + --add virtualMachineProfile.networkProfile.networkInterfaceConfigurations[0].ipConfigurations[0].loadBalancerBackendAddressPools "{'id':'/subscriptions/SubscriptionID/resourceGroups/myResourceGroup /providers/Microsoft.Network/loadBalancers/MyLb/backendAddressPools/mybackend'}" |
| 96 | +
|
| 97 | +``` |
| 98 | + |
| 99 | +1. Repeat the steps to attach your second Virtual Machine Scale Set to the backend pool of the Azure Load Balancer with `az vmss update`. |
| 100 | + |
| 101 | +--- |
| 102 | +## Next steps |
| 103 | + |
| 104 | +In this article, you attached multiple Virtual Machine Scale Sets behind a single Azure load balancer. |
| 105 | + |
| 106 | +- [What is Azure Load Balancer?](load-balancer-overview.md) |
| 107 | +- [What are Azure Virtual Machine Scale Sets?](../virtual-machine-scale-sets/overview.md) |
0 commit comments