Adding additional VIP to Azure Load Balancer

Recently, a partner needed guidance on adding an additional VIP to an Azure Load Balancer. This is a typical scenario where multiple SSL-based websites are running on a pair of servers and clients may not have SNI support, necessitating dedicated public IP’s for each website. Azure Load Balancer in Azure Resource Manager does support multiple VIP’s, just not via the portal. Not to worry, Powershell to the rescue. The Azure documentation site has a great article describing the process of deploying a two-node web farm and internet facing load balancer. These commands assume you’ve already deployed the load balancer and are just adding a second VIP:

Login-AzureRmAccount
Select-AzureRmSubscription -SubscriptionId 00000000-0000-0000-0000-000000000000
 
#Get the Resource Group
$rg = Get-AzureRmResourceGroup -Name "MultiVIPLBRG"
 
#Get the Load Balancer
$slb = Get-AzureRmLoadBalancer -Name "MultiVIPLB" -ResourceGroupName $rg.ResourceGroupName
 
#Create new public VIP
$vip2 = New-AzureRmPublicIpAddress -Name "PublicVIP2" -ResourceGroupName $rg.ResourceGroupName -Location $rg.Location -AllocationMethod Dynamic
 
#Create new Frontend IP Configuration using new VIP
$feipconfig2 = New-AzureRmLoadBalancerFrontendIpConfig -Name "MultiVIPLB-FE2" -PublicIpAddress $vip2
$slb | Add-AzureRmLoadBalancerFrontendIpConfig -Name "MultiVIPLB-FE2" -PublicIpAddress $vip2
 
#Get Backend Pool
$bepool = $slb | Get-AzureRmLoadBalancerBackendAddressPoolConfig
 
#Create new Probe
$probe2 = New-AzureRmLoadBalancerProbeConfig -Name "Probe2" -RequestPath "/" -Protocol http -Port 81 -IntervalInSeconds 5 -ProbeCount 2
$slb | Add-AzureRmLoadBalancerProbeConfig -Name "Probe2" -RequestPath "/" -Protocol http -Port 81 -IntervalInSeconds 5 -ProbeCount 2
 
#Create Load Balancing Rule
$slb | Add-AzureRmLoadBalancerRuleConfig -Name Rule2 -FrontendIpConfiguration $feipconfig2 -BackendAddressPool $bepool -Probe $probe2 -Protocol TCP -FrontendPort 80 -BackendPort 81
 
#Save the configuration
$slb | Set-AzureRmLoadBalancer

9 thoughts on “Adding additional VIP to Azure Load Balancer

  1. Hi Jeff,

    This article is great, thank you for posting this. Is there a limit on the number of VIPs that can be on one load balancer? Can this be used for multiple VIPs?

    Lastly (and I think/hope this is my last question), for this command in your script “$vip2 = New-AzureRmPublicIpAddress -Name “PublicVIP2″ -ResourceGroupName $rg.ResourceGroupName -Location $rg.Location -AllocationMethod Dynamic”, can the allocation method flag be set to static?

  2. Thanks Jeff. One final question. If I set up load balancer rules for ports 80 and 443, is the load balancer smart enough to be able to send the traffic to the correct site in IIS when using host headers?

  3. Hi Jeff,

    Thanks for the post, it has been really useful.

    After adding the 2nd IP should this appear in the Overview pane in the azure portal as its only showing 1 public ip address?

    Thanks

    • Hi Ashley,

      unfortunately, It does not show in the overview pane for the load balancer. But if you go to the public IP addresses and click each one, it will show which load balancer it is allocated to, if allocated.

      Good luck!

  4. Hi Jeff,

    Just what i need, for creating VIP in Azure.
    One question, could we share the VIP to multiple VM?

    Thanks
    Nagaraju

Leave a Reply

Your email address will not be published. Required fields are marked *