Steps To Configure Internal Load Balancer In Azure

Follow below steps to create Internal Load balance in Azure

  1. Create cloud service from Azure portal (or you can create via PowerShell).

    Create

  2. Create Virtual network “<VirtualNetworkName>” and then create subnet “<SubnetName>” from Azure wizard.

    (Please note that here we have static IP range 10.202.198.68 - 10.202.198.94) [Refer highlighted range in below image]

    Create

    Create

  3. Create two VMs in “<CloudServiceName>” service as “PLSQLCLSTR01XXQ” and “PLSQLCLSTR02XXQ”.

    Create

  4. Create internal load balance and add these VMs into it. Following is the script to create ILB and adding VMs into it.

    Script 1: downloads the subscription file

    Get-AzurePublishSettingsFile

    Script 2: Import the subscription file as default in windows Azure PowerShell session.

    Import-AzurePublishSettingsFile -PublishSettingsFile C:\SQLClustorPOC\<PublishSettingFileName>.publishsettings

    Note

    C:\SQLClustorPOC\<PublishSettingFileName>.publishsettings is path of publish setting file where it is downloaded.

    Script 3: creates ILB and set the

    # Define variables
    $ServiceName = "<ServiceName>" # the name of the cloud service that contains the availability group nodes
    $AGNodes = "<Node1>","PLSQLCLSTR02XXQ" # all availability group nodes containing replicas in the same cloud service, separated by commas
    $EndpointName = "TestEndpoint" # name of the endpoint
    $EndpointPort = "1433" # public port to use for the endpoint
    $ILBName = "TestInternalLoadBalancer" # chosen name for the new ILB
    $SubnetName = "afms_w_vnw_ptdb" # subnet name that the replicas use in the VNet
    $ILBStaticIP = "10.202.198.74" # static IP address for the ILB in the subnet

    Add-AzureInternalLoadBalancer -InternalLoadBalancerName $ILBName -SubnetName $SubnetName -ServiceName $ServiceName -StaticVNetIPAddress $ILBStaticIP

    # Configure a load balanced endpoint for each node in $AGNodes using ILB
    ForEach ($node in $AGNodes)
    {
    Get-AzureVM -ServiceName $ServiceName -Name $node | Add-AzureEndpoint -Name $EndpointName -LBSetName "$EndpointName-LB" -Protocol tcp -LocalPort $EndpointPort -PublicPort $EndpointPort -ProbePort 59999 -ProbeProtocol tcp -ProbeIntervalInSeconds 10 -InternalLoadBalancerName $ILBName -DirectServerReturn $true | Update-AzureVM
    }


  5. Once ILB gets created and ILB Endpoints are configured to those VMs, you can see below output:

    output

  6. The Azure Management Portal is not showing the Internal Load Balancer configuration, so you will not be able to check ILB or the endpoints. However, Get-AzureEndpoint command returns an internal IP address if the Load Balancer is configured and running on it. Otherwise, it returns null.

    Get-AzureVM -ServiceName "<CloudServiceName>" -Name "<VMName>" | Get-AzureEndpoint

    Below is the output of this command (Note that TestEndPoint-LB is created for VM “PLSQLCLSTR02XXQ”) :

    output

Steps to remove ILB

Step 1

First remove all the endpoints of VMs which are pointing to ILB. Below is the script to remove Endpoint of VM (run this script for all the VMs in that Load Balancer which contains End Points):

Get-AzureVM -ServiceName "<CloudServiceName>" -Name "<VMName>" | Remove-AzureEndpoint -Name "TestEndpoint"| Update-AzureVM

output

Step 2

Now check If that EndPoint is removed or not, to do this use below script, it displays all the endpoints except for the EndPoint which we have removed in Step 1.

Get-AzureVM -ServiceName "<CloudServiceName>" -Name "<VMName>" | Get-AzureEndpoint

Step 3

Next Step is to remove the Internal Load Balance, Use below script:

Remove-AzureInternalLoadBalancer -ServiceName "<CloudServiceName>"

output

This will successfully remove Internal Load Balance.


Similar Articles