|
| 1 | +--- |
| 2 | +title: "Quickstart: Create a public load balancer - Bicep" |
| 3 | +titleSuffix: Azure Load Balancer |
| 4 | +description: This quickstart shows how to create a load balancer by using a Bicep file. |
| 5 | +services: load-balancer |
| 6 | +documentationcenter: na |
| 7 | +author: mumian |
| 8 | +ms.service: load-balancer |
| 9 | +ms.topic: quickstart |
| 10 | +ms.tgt_pltfrm: na |
| 11 | +ms.workload: infrastructure-services |
| 12 | +ms.date: 08/17/2022 |
| 13 | +ms.author: jgao |
| 14 | +ms.custom: mvc, subject-bicepqs, mode-arm |
| 15 | +#Customer intent: I want to create a load balancer by using a Bicep file so that I can load balance internet traffic to VMs. |
| 16 | +--- |
| 17 | + |
| 18 | +# Quickstart: Create a public load balancer to load balance VMs by using a Bicep file |
| 19 | + |
| 20 | +Load balancing provides a higher level of availability and scale by spreading incoming requests across multiple virtual machines (VMs). |
| 21 | + |
| 22 | +This quickstart shows you how to deploy a standard load balancer to load balance virtual machines. |
| 23 | + |
| 24 | +Using a Bicep file takes fewer steps comparing to other deployment methods. |
| 25 | + |
| 26 | +[!INCLUDE [About Bicep](../../includes/resource-manager-quickstart-bicep-introduction.md)] |
| 27 | + |
| 28 | +## Prerequisites |
| 29 | + |
| 30 | +If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin. |
| 31 | + |
| 32 | +## Review the Bicep file |
| 33 | + |
| 34 | +The Bicep file used in this quickstart is from [Azure Quickstart Templates](https://azure.microsoft.com/resources/templates/load-balancer-standard-create/). |
| 35 | + |
| 36 | +Load balancer and public IP SKUs must match. When you create a standard load balancer, you must also create a new standard public IP address that is configured as the frontend for the standard load balancer. If you want to create a basic load balancer, use [this template](https://azure.microsoft.com/resources/templates/2-vms-loadbalancer-natrules/). Microsoft recommends using standard SKU for production workloads. |
| 37 | + |
| 38 | +:::code language="bicep" source="~/quickstart-templates/quickstarts/microsoft.network/load-balancer-standard-create/main.bicep"::: |
| 39 | + |
| 40 | +Multiple Azure resources have been defined in the bicep file: |
| 41 | + |
| 42 | +- [**Microsoft.Network/loadBalancers**](/azure/templates/microsoft.network/loadbalancers) |
| 43 | +- [**Microsoft.Network/publicIPAddresses**](/azure/templates/microsoft.network/publicipaddresses): for the load balancer, bastion host, and for each of the three virtual machines. |
| 44 | +- [**Microsoft.Network/bastionHosts**](/azure/templates/microsoft.network/bastionhosts) |
| 45 | +- [**Microsoft.Network/networkSecurityGroups**](/azure/templates/microsoft.network/networksecuritygroups) |
| 46 | +- [**Microsoft.Network/virtualNetworks**](/azure/templates/microsoft.network/virtualnetworks) |
| 47 | +- [**Microsoft.Compute/virtualMachines**](/azure/templates/microsoft.compute/virtualmachines) (3). |
| 48 | +- [**Microsoft.Network/networkInterfaces**](/azure/templates/microsoft.network/networkinterfaces) (3). |
| 49 | +- [**Microsoft.Compute/virtualMachine/extensions**](/azure/templates/microsoft.compute/virtualmachines/extensions) (3): use to configure the Internet Information Server (IIS), and the web pages. |
| 50 | + |
| 51 | +To find more Bicep files or ARM templates that are related to Azure Load Balancer, see [Azure Quickstart Templates](https://azure.microsoft.com/resources/templates/?resourceType=Microsoft.Network&pageNumber=1&sort=Popular). |
| 52 | + |
| 53 | +## Deploy the Bicep file |
| 54 | + |
| 55 | +1. Save the Bicep file as **main.bicep** to your local computer. |
| 56 | +1. Deploy the Bicep file using either Azure CLI or Azure PowerShell. |
| 57 | + |
| 58 | + # [CLI](#tab/CLI) |
| 59 | + |
| 60 | + ```azurecli |
| 61 | + az group create --name exampleRG --location centralus |
| 62 | + az deployment group create --resource-group exampleRG --template-file main.bicep |
| 63 | + ``` |
| 64 | +
|
| 65 | + # [PowerShell](#tab/PowerShell) |
| 66 | +
|
| 67 | + ```azurepowershell |
| 68 | + New-AzResourceGroup -Name exampleRG -Location centralus |
| 69 | + New-AzResourceGroupDeployment -ResourceGroupName exampleRG -TemplateFile ./main.bicep |
| 70 | + ``` |
| 71 | +
|
| 72 | + --- |
| 73 | +
|
| 74 | + > [!NOTE] |
| 75 | + > The Bicep file deployment creates three availability zones. Availability zones are supported only in [certain regions](../availability-zones/az-overview.md). Use one of the supported regions. If you aren't sure, enter **centralus**. |
| 76 | +
|
| 77 | + You will be prompted to enter the following values: |
| 78 | +
|
| 79 | + - **projectName**: used for generating resource names. |
| 80 | + - **adminUsername**: virtual machine administrator username. |
| 81 | + - **adminPassword**: virtual machine administrator password. |
| 82 | +
|
| 83 | +It takes about 10 minutes to deploy the Bicep file. |
| 84 | +
|
| 85 | +## Review deployed resources |
| 86 | +
|
| 87 | +1. Sign in to the [Azure portal](https://portal.azure.com). |
| 88 | +
|
| 89 | +1. Select **Resource groups** from the left pane. |
| 90 | +
|
| 91 | +1. Select the resource group that you created in the previous section. The default resource group name is **exampleRG**. |
| 92 | +
|
| 93 | +1. Select the load balancer. Its default name is the project name with **-lb** appended. |
| 94 | +
|
| 95 | +1. Copy only the IP address part of the public IP address, and then paste it into the address bar of your browser. |
| 96 | +
|
| 97 | + :::image type="content" source="./media/quickstart-load-balancer-standard-public-template/azure-standard-load-balancer-resource-manager-template-deployment-public-ip.png" alt-text="Screenshot of Azure standard load balancer Resource Manager template public IP."::: |
| 98 | +
|
| 99 | + The browser displays the default page of the Internet Information Services (IIS) web server. |
| 100 | +
|
| 101 | + :::image type="content" source="./media/quickstart-load-balancer-standard-public-template/load-balancer-test-web-page.png" alt-text="Screenshot of IIS web server."::: |
| 102 | +
|
| 103 | +To see the load balancer distribute traffic across all three VMs, you can force a refresh of your web browser from the client machine. |
| 104 | +
|
| 105 | +## Clean up resources |
| 106 | +
|
| 107 | +When you no longer need them, delete the: |
| 108 | +
|
| 109 | +- Resource group |
| 110 | +- Load balancer |
| 111 | +- Related resources |
| 112 | +
|
| 113 | +Go to the Azure portal, select the resource group that contains the load balancer, and then select **Delete resource group**. |
| 114 | +
|
| 115 | +## Next steps |
| 116 | +
|
| 117 | +In this quickstart, you: |
| 118 | +
|
| 119 | +- Created a virtual network for the load balancer and virtual machines. |
| 120 | +- Created an Azure Bastion host for management. |
| 121 | +- Created a standard load balancer and attached VMs to it. |
| 122 | +- Configured the load-balancer traffic rule, and the health probe. |
| 123 | +- Tested the load balancer. |
| 124 | +
|
| 125 | +To learn more, continue to the tutorials for Azure Load Balancer. |
| 126 | +
|
| 127 | +> [!div class="nextstepaction"] |
| 128 | +> [Azure Load Balancer tutorials](./quickstart-load-balancer-standard-public-portal.md) |
0 commit comments