|
| 1 | +--- |
| 2 | +title: 'Quickstart: Create an internal Azure load balancer using Bicep' |
| 3 | +description: This quickstart shows how to create an internal Azure load balancer using Bicep. |
| 4 | +services: load-balancer |
| 5 | +author: schaffererin |
| 6 | +ms.service: load-balancer |
| 7 | +ms.topic: quickstart |
| 8 | +ms.custom: subject-armqs, mode-arm |
| 9 | +ms.author: v-eschaffer |
| 10 | +ms.date: 04/29/2022 |
| 11 | +--- |
| 12 | + |
| 13 | +# Quickstart: Create an internal load balancer to load balance VMs by using Bicep |
| 14 | + |
| 15 | +This quickstart describes how to use Bicep to create an internal Azure load balancer. |
| 16 | + |
| 17 | +[!INCLUDE [About Bicep](../../includes/resource-manager-quickstart-bicep-introduction.md)] |
| 18 | + |
| 19 | +## Prerequisites |
| 20 | + |
| 21 | +If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin. |
| 22 | + |
| 23 | +## Review the Bicep file |
| 24 | + |
| 25 | +The Bicep file used in this quickstart is from the [Azure Quickstart Templates](https://azure.microsoft.com/resources/templates/2-vms-internal-load-balancer/). |
| 26 | + |
| 27 | +:::code language="bicep" source="~/quickstart-templates/quickstarts/microsoft.compute/2-vms-internal-load-balancer/main.bicep"::: |
| 28 | + |
| 29 | +Multiple Azure resources have been defined in the Bicep file: |
| 30 | + |
| 31 | +- [**Microsoft.Storage/storageAccounts**](/azure/templates/microsoft.storage/storageaccounts): Virtual machine storage accounts for boot diagnostics. |
| 32 | +- [**Microsoft.Compute/availabilitySets**](/azure/templates/microsoft.compute/availabilitySets): Availability set for virtual machines. |
| 33 | +- [**Microsoft.Network/virtualNetworks**](/azure/templates/microsoft.network/virtualNetworks): Virtual network for load balancer and virtual machines. |
| 34 | +- [**Microsoft.Network/networkInterfaces**](/azure/templates/microsoft.network/networkInterfaces): Network interfaces for virtual machines. |
| 35 | +- [**Microsoft.Network/loadBalancers**](/azure/templates/microsoft.network/loadBalancers): Internal load balancer. |
| 36 | +- [**Microsoft.Compute/virtualMachines**](/azure/templates/microsoft.compute/virtualMachines): Virtual machines. |
| 37 | + |
| 38 | +## Deploy the Bicep file |
| 39 | + |
| 40 | +1. Save the Bicep file as **main.bicep** to your local computer. |
| 41 | +1. Deploy the Bicep file using either Azure CLI or Azure PowerShell. |
| 42 | + |
| 43 | + # [CLI](#tab/CLI) |
| 44 | + |
| 45 | + ```azurecli |
| 46 | + az group create --name exampleRG --location eastus |
| 47 | + az deployment group create --resource-group exampleRG --template-file main.bicep --parameters adminUsername=<admin-user> |
| 48 | + ``` |
| 49 | +
|
| 50 | + # [PowerShell](#tab/PowerShell) |
| 51 | +
|
| 52 | + ```azurepowershell |
| 53 | + New-AzResourceGroup -Name exampleRG -Location eastus |
| 54 | + New-AzResourceGroupDeployment -ResourceGroupName exampleRG -TemplateFile ./main.bicep -adminUsername "<admin-user>" |
| 55 | + ``` |
| 56 | +
|
| 57 | + --- |
| 58 | +
|
| 59 | + > [!NOTE] |
| 60 | + > Replace **\<admin-user\>** with the admin username. You'll also be prompted to enter **adminPassword**. |
| 61 | +
|
| 62 | + When the deployment finishes, you should see a message indicating the deployment succeeded. |
| 63 | +
|
| 64 | +## Review deployed resources |
| 65 | +
|
| 66 | +Use the Azure portal, Azure CLI, or Azure PowerShell to list the deployed resources in the resource group. |
| 67 | +
|
| 68 | +# [CLI](#tab/CLI) |
| 69 | +
|
| 70 | +```azurecli-interactive |
| 71 | +az resource list --resource-group exampleRG |
| 72 | +``` |
| 73 | + |
| 74 | +# [PowerShell](#tab/PowerShell) |
| 75 | + |
| 76 | +```azurepowershell-interactive |
| 77 | +Get-AzResource -ResourceGroupName exampleRG |
| 78 | +``` |
| 79 | + |
| 80 | +--- |
| 81 | + |
| 82 | +## Clean up resources |
| 83 | + |
| 84 | +When no longer needed, use the Azure portal, Azure CLI, or Azure PowerShell to delete the resource group and its resources. |
| 85 | + |
| 86 | +# [CLI](#tab/CLI) |
| 87 | + |
| 88 | +```azurecli-interactive |
| 89 | +az group delete --name exampleRG |
| 90 | +``` |
| 91 | + |
| 92 | +# [PowerShell](#tab/PowerShell) |
| 93 | + |
| 94 | +```azurepowershell-interactive |
| 95 | +Remove-AzResourceGroup -Name exampleRG |
| 96 | +``` |
| 97 | + |
| 98 | +--- |
| 99 | + |
| 100 | +## Next steps |
| 101 | + |
| 102 | +For a step-by-step tutorial that guides you through the process of creating a Bicep file, see: |
| 103 | + |
| 104 | +> [!div class="nextstepaction"] |
| 105 | +> [Quickstart: Create Bicep files with Visual Studio Code](../azure-resource-manager/bicep/quickstart-create-bicep-use-visual-studio-code.md) |
0 commit comments