Create a public load balancer to load balance VMs

  1. Home
  2. Create a public load balancer to load balance VMs

Go back to Tutorial

In this we will get started with Azure Load Balancer by using Azure PowerShell to create a public load balancer and three virtual machines.

Create a resource group

An Azure resource group is a logical container into which Azure resources are deployed and managed.

However, Create a resource group with New-AzResourceGroup:

Azure PowerShell:
New-AzResourceGroup -Name ‘CreatePubLBQS-rg’ -Location ‘eastus’

Create a public IP address – Standard

Use New-AzPublicIpAddress to create a public IP address.

Azure PowerShell:
$publicip = @{
Name = ‘myPublicIP’
ResourceGroupName = ‘CreatePubLBQS-rg’
Location = ‘eastus’
Sku = ‘Standard’
AllocationMethod = ‘static’
}
New-AzPublicIpAddress @publicip

Secondly, to create a zonal public IP address in zone 1, use the following command:

Azure PowerShell:
$publicip = @{
Name = ‘myPublicIP’
ResourceGroupName = ‘CreatePubLBQS-rg’
Location = ‘eastus’
Sku = ‘Standard’
AllocationMethod = ‘static’
Zone = ‘1’
}
New-AzPublicIpAddress @publicip

Create standard load balancer

This section details how you can create and configure the following components of the load balancer:

  • Firstly, Create a front-end IP with New-AzLoadBalancerFrontendIpConfig for the frontend IP pool. This IP receives the incoming traffic on the load balancer
  • Secondly, Create a back-end address pool with New-AzLoadBalancerBackendAddressPoolConfig for traffic sent from the frontend of the load balancer. This pool is where your backend virtual machines are deployed.
  • Thirdly, Create a health probe with Add-AzLoadBalancerProbeConfig that determines the health of the backend VM instances.
  • Then, Create a load balancer rule with Add-AzLoadBalancerRuleConfig that defines how traffic is distributed to the VMs.
  • Lastly, Create a public load balancer with New-AzLoadBalancer.
AZ-104  practice tests

Configure virtual network – Standard

Before you deploy VMs and test your load balancer, create the supporting virtual network resources. After that, create a virtual network for the backend virtual machines. Then, create a network security group to define inbound connections to your virtual network.

Create virtual network, network security group, and bastion host
  • Firstly, create a virtual network with New-AzVirtualNetwork.
  • Secondly, create a network security group rule with New-AzNetworkSecurityRuleConfig.
  • Then, create an Azure Bastion host with New-AzBastion.
  • Lastly, create a network security group with New-AzNetworkSecurityGroup.

Create outbound rule configuration

Load balancer outbound rules configure outbound source network address translation (SNAT) for VMs in the backend pool.

Create outbound public IP address

Use New-AzPublicIpAddress to create a standard zone redundant public IP address named myPublicIPOutbound.

Azure PowerShell:
$publicipout = @{
Name = ‘myPublicIPOutbound’
ResourceGroupName = ‘CreatePubLBQS-rg’
Location = ‘eastus’
Sku = ‘Standard’
AllocationMethod = ‘static’
}
New-AzPublicIpAddress @publicipout

Next, to create a zonal public IP address in zone 1, use the following command:

Azure PowerShell:
$publicipout = @{
Name = ‘myPublicIPOutbound’
ResourceGroupName = ‘CreatePubLBQS-rg’
Location = ‘eastus’
Sku = ‘Standard’
AllocationMethod = ‘static’
Zone = ‘1’
}
New-AzPublicIpAddress @publicipout

Create outbound configuration

  • Firstly, create a new frontend IP configuration with Add-AzLoadBalancerFrontendIpConfig.
  • Secondly, create a new outbound pool with Add-AzLoadBalancerBackendAddressPoolConfig.
  • Thirdly, apply the pool and frontend IP address to the load balancer with Set-AzLoadBalancer.
  • Lastly, Create a new outbound rule for the outbound backend pool with Add-AzLoadBalancerOutboundRuleConfig.
Create a public load balancer to load balance VMs AZ-104 online course

Reference: Microsoft Documentation

Go back to Tutorial

Menu