|
| 1 | +--- |
| 2 | +title: 'Tutorial: Create an internal load balancer - Azure portal' |
| 3 | +titleSuffix: Azure Load Balancer |
| 4 | +description: This tutorial shows you how to create an internal Standard load balancer by using the Azure portal. |
| 5 | +services: load-balancer |
| 6 | +documentationcenter: na |
| 7 | +author: asudbring |
| 8 | +manager: twooley |
| 9 | +Customer intent: As an IT administrator, I want to create a load balancer that load balances incoming internal traffic to virtual machines within a specific zone in a region. |
| 10 | +ms.service: load-balancer |
| 11 | +ms.devlang: na |
| 12 | +ms.topic: tutorial |
| 13 | +ms.tgt_pltfrm: na |
| 14 | +ms.workload: infrastructure-services |
| 15 | +ms.date: 01/08/2020 |
| 16 | +ms.author: allensu |
| 17 | +ms.custom: seodec18 |
| 18 | +--- |
| 19 | + |
| 20 | +# Tutorial: Balance internal traffic load with a Standard load balancer in the Azure portal |
| 21 | + |
| 22 | +Load balancing provides a higher level of availability and scale by spreading incoming requests across virtual machines (VMs). You can use the Azure portal to create a Standard load balancer and balance internal traffic among VMs. This tutorial shows you how to create and configure an internal load balancer, back-end servers, and network resources at the standard pricing tier. |
| 23 | + |
| 24 | +If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin. |
| 25 | + |
| 26 | +If you prefer, you can do these steps using the [Azure CLI](load-balancer-get-started-ilb-arm-cli.md) or [Azure PowerShell](load-balancer-get-started-ilb-arm-ps.md) instead of the portal. |
| 27 | + |
| 28 | +To do the steps using this tutorial, sign in to the Azure portal at [https://portal.azure.com](https://portal.azure.com). |
| 29 | + |
| 30 | +## Create a VNet, back-end servers, and a test VM |
| 31 | + |
| 32 | +First, create a virtual network (VNet). In the VNet, create two VMs to use for the backend pool of your Standard load balancer, and a third VM to use for testing the load balancer. |
| 33 | + |
| 34 | +### Create a virtual network |
| 35 | + |
| 36 | +1. On the upper-left side of the portal, select **Create a resource** > **Networking** > **Virtual network**. |
| 37 | + |
| 38 | +1. In the **Create virtual network** pane, type or select these values: |
| 39 | + |
| 40 | + - **Name**: Type **MyVNet**. |
| 41 | + - **ResourceGroup**: Select **Create new**, then enter **MyResourceGroupLB**, and select **OK**. |
| 42 | + - **Subnet** > **Name**: Type **MyBackendSubnet**. |
| 43 | + |
| 44 | +1. Select **Create**. |
| 45 | + |
| 46 | +  |
| 47 | + |
| 48 | +### Create virtual machines |
| 49 | + |
| 50 | +1. On the upper-left side of the portal, select **Create a resource** > **Compute** > **Windows Server 2016 Datacenter**. |
| 51 | + |
| 52 | +1. In **Create a virtual machine**, type or select the following values in the **Basics** tab: |
| 53 | + - **Subscription** > **Resource Group**: Drop down and select **MyResourceGroupLB**. |
| 54 | + - **Instance Details** > **Virtual machine name**: Type **MyVM1**. |
| 55 | + - **Instance Details** > **Region**: Select **East US 2**. |
| 56 | + |
| 57 | + |
| 58 | +1. Select the **Networking** tab, or select **Next: Disks**, then **Next: Networking**. |
| 59 | + |
| 60 | + Make sure the following are selected: |
| 61 | + - **Virtual network**: **MyVNet** |
| 62 | + - **Subnet**: **MyBackendSubnet** |
| 63 | + - **NIC network security group**: Select **Basic**. |
| 64 | + - **Public IP** > Select **Create new** and enter the following values and select **OK**: |
| 65 | + - **Name**: **MyVM1-IP** |
| 66 | + - **SKU**: Select **Standard** |
| 67 | + - **Public inbound ports**: Select **Allow selected ports**. |
| 68 | + - **Select inbound ports**: Drop down and select **RDP (3389)** |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | +1. Select the **Management** tab, or select **Next** > **Management**. Under **Monitoring**, set **Boot diagnostics** to **Off**. |
| 73 | + |
| 74 | +1. Select **Review + create**. |
| 75 | + |
| 76 | +1. Review the settings, and then select **Create**. |
| 77 | + |
| 78 | +1. Follow the steps to create a second VM named **MyVM2**, with all the other settings the same as MyVM1. |
| 79 | + |
| 80 | +1. Follow the steps again to create a third VM named **MyTestVM**. |
| 81 | + |
| 82 | +## Create a Standard load balancer |
| 83 | + |
| 84 | +Create a standard internal load balancer by using the portal. The name and IP address you create are automatically configured as the load balancer's front end. |
| 85 | + |
| 86 | +1. On the upper-left side of the portal, select **Create a resource** > **Networking** > **Load Balancer**. |
| 87 | + |
| 88 | +2. In the **Basics** tab of the **Create load balancer** page, enter or select the following information, accept the defaults for the remaining settings, and then select **Review + create**: |
| 89 | + |
| 90 | + | Setting | Value | |
| 91 | + | --- | --- | |
| 92 | + | Subscription | Select your subscription. | |
| 93 | + | Resource group | Select **Create new** and type *MyResourceGroupLB* in the text box.| |
| 94 | + | Name | *myLoadBalancer* | |
| 95 | + | Region | Select **East US 2**. | |
| 96 | + | Type | Select **Internal**. | |
| 97 | + | SKU | Select **Standard**. | |
| 98 | + | Virtual network | Select *MyVNet*. | |
| 99 | + | IP address assignment | Select **Static**. | |
| 100 | + | Private IP address|Type an address that is in the address space of your virtual network and subnet, for example *10.3.0.7*. | |
| 101 | + |
| 102 | +3. In the **Review + create** tab, click **Create**. |
| 103 | + |
| 104 | + |
| 105 | +## Create Standard load balancer resources |
| 106 | + |
| 107 | +In this section, you configure load balancer settings for a back-end address pool and a health probe, and specify load balancer rules. |
| 108 | + |
| 109 | +### Create a back-end address pool |
| 110 | + |
| 111 | +To distribute traffic to the VMs, the load balancer uses a back-end address pool. The back-end address pool contains the IP addresses of the virtual network interfaces (NICs) that are connected to the load balancer. |
| 112 | + |
| 113 | +**To create a back-end address pool that includes VM1 and VM2:** |
| 114 | + |
| 115 | +1. Select **All resources** on the left menu, and then select **MyLoadBalancer** from the resource list. |
| 116 | + |
| 117 | +1. Under **Settings**, select **Backend pools**, and then select **Add**. |
| 118 | + |
| 119 | +1. On the **Add a backend pool** page, type or select the following values: |
| 120 | + |
| 121 | + - **Name**: Type **MyBackendPool**. |
| 122 | + |
| 123 | +1. Under **Virtual machines**. |
| 124 | + 1. Add **MyVM1** and **MyVM2** to the back-end pool. |
| 125 | + 2. After you add each machine, drop down and select its **Network IP configuration**. |
| 126 | + |
| 127 | +1. Select **Add**. |
| 128 | + |
| 129 | +  |
| 130 | + |
| 131 | +1. On the **Backend pools** page, expand **MyBackendPool** and make sure both **VM1** and **VM2** are listed. |
| 132 | + |
| 133 | +### Create a health probe |
| 134 | + |
| 135 | +To allow the load balancer to monitor VM status, you use a health probe. The health probe dynamically adds or removes VMs from the load balancer rotation based on their response to health checks. |
| 136 | + |
| 137 | +**To create a health probe to monitor the health of the VMs:** |
| 138 | + |
| 139 | +1. Select **All resources** on the left menu, and then select **MyLoadBalancer** from the resource list. |
| 140 | + |
| 141 | +1. Under **Settings**, select **Health probes**, and then select **Add**. |
| 142 | + |
| 143 | +1. On the **Add a health probe** page, type or select the following values: |
| 144 | + |
| 145 | + - **Name**: Type **MyHealthProbe**. |
| 146 | + - **Protocol**: Drop down and select **HTTP**. |
| 147 | + - **Port**: Type **80**. |
| 148 | + - **Path**: Accept **/** for the default URI. You can replace this value with any other URI. |
| 149 | + - **Interval**: Type **15**. Interval is the number of seconds between probe attempts. |
| 150 | + - **Unhealthy threshold**: Type **2**. This value is the number of consecutive probe failures that occur before a VM is considered unhealthy. |
| 151 | + |
| 152 | +1. Select **OK**. |
| 153 | + |
| 154 | +  |
| 155 | + |
| 156 | +### Create a load balancer rule |
| 157 | + |
| 158 | +A load balancer rule defines how traffic is distributed to the VMs. The rule defines the front-end IP configuration for incoming traffic, the back-end IP pool to receive the traffic, and the required source and destination ports. |
| 159 | + |
| 160 | +The load balancer rule named **MyLoadBalancerRule** listens to port 80 in the front-end **LoadBalancerFrontEnd**. The rule sends network traffic to the back-end address pool **MyBackendPool**, also on port 80. |
| 161 | + |
| 162 | +**To create the load balancer rule:** |
| 163 | + |
| 164 | +1. Select **All resources** on the left menu, and then select **MyLoadBalancer** from the resource list. |
| 165 | + |
| 166 | +1. Under **Settings**, select **Load balancing rules**, and then select **Add**. |
| 167 | + |
| 168 | +1. On the **Add load balancing rule** page, type or select the following values, if not already present: |
| 169 | + |
| 170 | + - **Name**: Type **MyLoadBalancerRule**. |
| 171 | + - **Frontend IP address:** Type **LoadBalancerFrontEnd** if not present. |
| 172 | + - **Protocol**: Select **TCP**. |
| 173 | + - **Port**: Type **80**. |
| 174 | + - **Backend port**: Type **80**. |
| 175 | + - **Backend pool**: Select **MyBackendPool**. |
| 176 | + - **Health probe**: Select **MyHealthProbe**. |
| 177 | + |
| 178 | +1. Select **OK**. |
| 179 | + |
| 180 | +  |
| 181 | + |
| 182 | +## Test the load balancer |
| 183 | + |
| 184 | +Install Internet Information Services (IIS) on the back-end servers, then use MyTestVM to test the load balancer using its private IP address. Each back-end VM serves a different version of the default IIS web page, so you can see the load balancer distribute requests between the two VMs. |
| 185 | + |
| 186 | +In the portal, on the **Overview** page for **MyLoadBalancer**, find its IP address under **Private IP Address**. Hover over the address and select the **Copy** icon to copy it. In this example, it is **10.3.0.7**. |
| 187 | + |
| 188 | +### Connect to the VMs with RDP |
| 189 | + |
| 190 | +First, connect to all three VMs with Remote Desktop (RDP). |
| 191 | + |
| 192 | +>[!NOTE] |
| 193 | +>By default, the VMs already have the **RDP** (Remote Desktop) port open to allow remote desktop access. |
| 194 | +
|
| 195 | +**To remote desktop (RDP) into the VMs:** |
| 196 | + |
| 197 | +1. In the portal, select **All resources** on the left menu. From the resource list, select each VM in the **MyResourceGroupLB** resource group. |
| 198 | + |
| 199 | +1. On the **Overview** page, select **Connect**, and then select **Download RDP file**. |
| 200 | + |
| 201 | +1. Open the RDP file you downloaded, and select **Connect**. |
| 202 | + |
| 203 | +1. On the Windows Security screen, select **More choices** and then **Use a different account**. |
| 204 | + |
| 205 | + Enter username and password and then select **OK**. |
| 206 | + |
| 207 | +1. Respond **Yes** to any certificate prompt. |
| 208 | + |
| 209 | + The VM desktop opens in a new window. |
| 210 | + |
| 211 | +### Install IIS and replace the default IIS page on the back-end VMs |
| 212 | + |
| 213 | +On each back-end server, use PowerShell to install IIS and replace the default IIS web page with a customized page. |
| 214 | + |
| 215 | +>[!NOTE] |
| 216 | +>You can also use the **Add Roles and Features Wizard** in **Server Manager** to install IIS. |
| 217 | +
|
| 218 | +**To install IIS and update the default web page with PowerShell:** |
| 219 | + |
| 220 | +1. On MyVM1 and on MyVM2, launch **Windows PowerShell** from the **Start** menu. |
| 221 | + |
| 222 | +2. Run the following commands to install IIS and replace the default IIS web page: |
| 223 | + |
| 224 | + ```powershell-interactive |
| 225 | + # Install IIS |
| 226 | + Install-WindowsFeature -name Web-Server -IncludeManagementTools |
| 227 | + |
| 228 | + # Remove default htm file |
| 229 | + remove-item C:\inetpub\wwwroot\iisstart.htm |
| 230 | + |
| 231 | + # Add custom htm file |
| 232 | + Add-Content -Path "C:\inetpub\wwwroot\iisstart.htm" -Value $("Hello World from " + $env:computername) |
| 233 | + ``` |
| 234 | +1. Close the RDP connections with MyVM1 and MyVM2 by selecting **Disconnect**. Do not shut down the VMs. |
| 235 | +
|
| 236 | +### Test the load balancer |
| 237 | +
|
| 238 | +1. On MyTestVM, open **Internet Explorer**, and respond **OK** to any configuration prompts. |
| 239 | + |
| 240 | +1. Paste or type the load balancer's private IP address (*10.3.0.7*) into the address bar of the browser. |
| 241 | + |
| 242 | + The customized IIS web server default page appears in the browser. The message reads either **Hello World from MyVM1**, or **Hello World from MyVM2**. |
| 243 | + |
| 244 | +1. Refresh the browser to see the load balancer distribute traffic across VMs. You may also need to clear your browser cache between attempts. |
| 245 | +
|
| 246 | + Sometimes the **MyVM1** page appears, and other times the **MyVM2** page appears, as the load balancer distributes the requests to each back-end VM. |
| 247 | +
|
| 248 | +  |
| 249 | + |
| 250 | +## Clean up resources |
| 251 | +
|
| 252 | +To delete the load balancer and all related resources when you no longer need them, open the **MyResourceGroupLB** resource group and select **Delete resource group**. |
| 253 | +
|
| 254 | +## Next steps |
| 255 | +
|
| 256 | +In this tutorial, you created a Standard internal load balancer. You created and configured network resources, back-end servers, a health probe, and rules for the load balancer. You installed IIS on the back-end VMs and used a test VM to test the load balancer in the browser. |
| 257 | +
|
| 258 | +Next, learn how to load balance VMs across availability zones. |
| 259 | +
|
| 260 | +> [!div class="nextstepaction"] |
| 261 | +> [Load balance VMs across availability zones](tutorial-load-balancer-standard-public-zone-redundant-portal.md) |
0 commit comments