0% found this document useful (0 votes)
92 views

Create An Internal Load Balancer Via Bicep

Uploaded by

Sanskar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
92 views

Create An Internal Load Balancer Via Bicep

Uploaded by

Sanskar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 7
1125124, 7:34 PM CQuickstan: Create an intemal Azure load balancer - Bicep | Microsoft Leam Quickstart: Create an internal load balancer to load balance VMs using Bicep Article + 05/01/2023 This quickstart describes how to use Bicep to create an internal Azure load balancer. Resource Group @ sy 0 mw 80: | M2 anes outers Fa | omens g nm e : + El teava NAT Gateway NAT Gateway Public IP Ls RDP/SSH Backend Subnet | soni ramon EE ©) Bastion Subnet > Virtual Network Bicep is a domain-specific language (DSL) that uses declarative syntax to deploy Azure resources. It provides concise syntax, reliable type safety, and support for code reuse. Bicep offers the best authoring experience for your infrastructure-as-code solutions in Azure. Prerequisites If you don't have an Azure subscription, create a free account _ before you begin. Review the Bicep file The Bicep file used in this quickstart is from the Azure Quickstart Templates nttps:leam microsot.comlon-usfazurelload-balanceriquickstartoae-balancor-sandar-intemal-bicep abs=CL wr ‘25124, 7:34 PM (Quickstar: Create an internal Azur load balancer - Bicep | Microsoft Lear Bicep @description( ‘Admin username’ ) param adminUsernane string @description('Admin password" ) @secure() param adminPassword string @description( ‘Prefix to use for VM names’) param vmNamePrefix string = 'BackendVm’ @description( ‘Location for all resources.") param location string = resourceGroup().location @description( ‘Size of the virtual machines’) param vnSize string = 'Standard_p2s_v3" var availabilitySetName = ‘AvSet’ var storageAccountType = ‘Standard_Lrs' var storageAccountName = uniqueString(resourceGroup() id) var virtualNetworkName = ‘vNet' var subnetName = "backendsubnet' var loadBalancerName = 'ilb’ var networkInterfaceName = ‘nic! var subnetRef = resourceld( ‘Microsoft .Network/virtualNetworks/subnets', virtu- alNetworkName, subnetName) var numberOfinstances = 2 resource storageAccount ‘Microsoft. Storage/storageAccounts@2021-08-01' = { name: storageAccountName location: location sku: { name: storageAccountType > kind: ‘Storagev2' resource availabilitySet ‘Microsoft.conpute/availabilitySets@2021-11-@1" = { name: availabilitySetName location: location sku: { name: ‘Aligned’ + properties: { platformUpdateDomaincount: 2 platformFaultbomaincount: 2 > + resource virtualNetwork "Microsoft .Network/virtualNetworks@2021-@5-01' = { ‘ntps:leam microsof. comier-usiazureload-balancerlquickstartloac-balancer-standardintemal-bcep7tabe=CL an 125124, 7:24 PM (Quickstar: Create an intemal Azure load balancer -Sicep| Microsoft Lea name: virtualNetworkName location: location properties: ( addressSpace: { addressPrefixe: "10.0.0.0/16" J + subnets: [ t properties: { addressPrefix: '10.0.2.0/24" subnetName resource networkInterface ‘Microsoft .Network/networkInterfaces@2@21-05-01' = [for i in range(@, numberOfInstances): { name: '${networkInterfaceNane}${i}" location: location properties: { ipConfigurations: [ t name: ‘ipconfig’ properties: { privateIPAllocationMethod: ‘Dynamic’ subnet: { id: subnetRef } loadBalancerBackendAddressPools: [ { id: resourceld( ‘Microsoft .Network/LoadBalancers/backendAddressPools’, loadBalancer- Name, 'BackendPool1') dependson: [ virtualNetwork JoadBalancer ] Ba resource loadBalancer ‘Microsoft .Network/loadBalancers@2021-05-@1' = { name: loadBalancerName ‘ntps:leam microsof. comier-usiazureload-balancerlquickstartloac-balancer-standardintemal-bcep7tabe=CL 1125124, 7:34 PM CQuickstar: Create an intemal Azure lad balancer -Sicep | Mcrosot Loam location: location sku: { name: ‘Standard’ ? properties: { frontendIPConfigurations: [ { properties: { subnet: { id: subnetRef + privaterPAddress: '10.0.2.6' privateIPAllocationMethod: ‘Static’ LoadBalancerFrontend’ loadBalancingRules: [ t properties: { frontendIPConfiguration: { id: resourceld( ‘Microsoft .Network/loadBalancers/frontendIpConfigurations', loadBal- ancerNane, ‘LoadBalancerFrontend' ) + backendAddressPool: ( id: resourceld( ‘Microsoft .Network/loadBalancers/backendAddressPools', loadBalancer- Name, 'BackendPool1") > probe: { id: resourceld( ‘Microsoft .Network/LoadBalancers/probes’, loadBal- ancerNane, ‘1bprobe') > protocol: 'Tcp' frontendPort: 80 backendPort: 8@ idleTimeoutInMinutes: 15 "Ibrule’ probes: [ { properties: { protocol: 'Tcp' ‘ntps:leam microsof. comier-usiazureload-balancerlquickstartloac-balancer-standardintemal-bcep7tabe=CL an 12524, 7:24 Pmt CQuickstan: Create an intemal Azure load balancer - Bicep | Microsoft Leam port: 80 intervalInSeconds: 15 nunberofProbes: 2 name: 'Lbprobe" dependson: [ virtualNetwork resource vm 'Microsoft.Compute/virtualMachines@2021-11-1' = [for i in range(®, numberofInstances): { name: ‘${vmNamePrefix}${i}' location: location properties: { availabilityset: { id: availabilityset.id + hardwareProfile: { vmsize vmsizi + osProfile: { computerName: '${vmNamePrefix}${i}" adminUsername: adminUsername adminPassword: adminPassword } storageProfile: { imageReference: { publisher: ‘MicrosoftWindowsServer* offer: WindowsServer" sku: '2019-Datacenter’ version: ‘latest’ } osDisk: { createOption: ‘FromImage’ + } networkProfile: { networkInterfaces: [ networkInterface[i] .id diagnosticsProfile: { bootDiagnostics: { enabled: true storageUri: storageAccount. properties. primaryEndpoints.blob ntips:leam microsot.comlon-uslazurelload-balanceriquickstartoae-balancor-sandar-intemal-bicep abs=CL 1125124, 734 PM Quickstar: Create an intemal Azure load balancer - Bicep | Microsoft Leam y i Multiple Azure resources have been defined in the Bicep file * Microsoft. Storage/storageAccounts: Virtual machine storage accounts for boot diagnostics. * Microsoft.Compute/availabilitySets: Availability set for virtual machines. ‘+ Microsoft.Network/virtualNetworks: Virtual network for load balancer and virtual machines. * Microsoft Network/networkinterfaces: Network interfaces for virtual machines. * Microsoft.Network/loadBalancers: Internal load balancer. ‘* Microsoft.Compute/virtualMachines: Virtual machines. Deploy the Bicep file 1. Save the Bicep file as main.bicep to your local computer. 2. Deploy the Bicep file using either Azure CLI or Azure PowerShell. cu Azure CU az group create --name CreateIntLBQS-rg --location eastus az deployment group create --resource-group CreateIntLBQS-rg plate-file main.bicep --parameters adminUsername=AzureAdmin © Note Replace with the admin username. You'll also be prompted to enter adminPassword. When the deployment finishes, you should see a message indicating the deployment succeeded nttps:leam microsot.comlon-usfazurelload-balanceriquickstartoae-balancor-sandar-intemal-bicep abs=CL 87 sna, 734 Pa dict: Cet nina Aare ed lancer cep | Mrs Leam Review deployed resources Use the Azure portal, Azure CLI, or Azure PowerShell to list the deployed resources in the resource group. cu ‘Azure CLI az resource list --resource-group CreateIntL8Qs-rg Clean up resources When no longer needed, use the Azure portal, Azure CLI, or Azure PowerShell to delete the resource group and its resources. cu Azure CLI az group delete --name CreateIntLags-rg Next steps For a step-by-step tutorial that guides you through the process of creating a Bicep file, see nttps:leam microsot.comlon-usfazurelload-balanceriquickstartoae-balancor-sandar-intemal-bicep abs=CL a

You might also like