Configuring an Availability Set with the Azure Load Balancer

According to Microsoft definition, “An availability set is a group of virtual machines that are deployed across fault domains and update domains. Availability sets make sure that your application is not affected by single points of failure, like the network switch or the power unit of a rack of servers.”
Each virtual machine is assigned an update domain and a fault domain:

  • Update domains define the group of VMs that can be updated and restarted at the same period. During planned maintenance, only one update domain is rebooted at a time. By default, there are 5 update domains and you can configure up to 20 update domains.
  • Fault domain define a group of VMs that share a common set of hardware, network switches and power source.

VMs in an availability set are placed in at least two fault domains. Microsoft recommends combing the Azure Load balancer with an availability set to get the most application resiliency.


The Azure Load Balancer enables you to distribute incoming traffic across the collections of VMs in an availability set in a round robin manner. It automatically removes un-healthy VMs from rotation so that they are not routed traffic when they are unavailable.

You can create a virtual machine and an availability set at the same time. Or you create an availability set and then add VMs to it. Here, you create an availability set, launch 2 Ubuntu VMs instances and then add new VMs as part of the availability set. Then, lastly configure a Load Balancer with availability set.

Configuring an Availability Set for 2 VMs:
1. On the upper-left side of the Azure Portal, click on Create a resource, in the search resources, type Availability and select Availability Set.

2. On the Availability Set page, click on Create button.

3. On the Create availability set page, type or select these values:

  • Name: Type MSSERVERPRO-AS
  • Resource Group: Select MSSERVERPRO-ASA-RG01
  • Location: Select Southeast Asia
  • Fault domains: 2
  • Update domains: 5
  • Use managed disks: Yes(Aligned)

Select Create button.

4. Go to All resources, select on newly created Availability Set name MSSERVEPRO-AS.

5. On the MSSERVERPRO-AS Availability Set page, verify the Fault domains (2) and Update domains (5).

Create 2 Ubuntu virtual machines with Availability option:
1. On the upper-left side of the portal, select Create a resource > Compute > Ubuntu Server 18.04 VM.

2. In the Create a virtual machine page, type or select the following values in the Basics tab:

  • PROJECT DETAILS >
    • Resource Group: Drop down and select MSSERVERPRO-ASA-RG01
    • INSTANCE DETAILS > Virtual machine name: Type KTM-WEBSRV01
    • Region: Select Southeast Asia
    • Availability options: Drop down and select Availability Set
    • Availability Set: Drop down and select MSSERVERPRO-AS
    • Image: Drop down and select Ubuntu Server 18.04 LTS
    • Size: Select Standard D2s v3
  • ADMINISTRATOR ACCOUNT >
    • Authentication Type: select Password.
    • Username: ktmadmin
    • Password: *********
    • Confirmed Password: *****
  • INBOUNT PORT RULE >
    • Public Inbound ports: Select Allow Selected ports.
    • Select inbound ports: Drop down and select HTTP, SSH.
Related Post  Creating a Windows Virtual Machine and Availability Set at the same time using the Azure Portal

Create on Next: Disks button.

3. In the Create a virtual machine page, type or select the following values in the Disks tab:

  • DISKS OPTIONS >
    • OS disk type: Drop and select Standard SSD.
  • ADVANCED >
    • Use managed disks: select Yes.

     Then click on Next: Networking button.

4. In the Create a virtual machine page, type or select the following values in the Networking tab:

Make sure the following options are selected:

  • Virtual network: Drop and select MSP-ASA-VN01
  • Subnet: Drop and select FrontEnd-Subnet(10.1.4.0/24)
  • Public IP: Drop and select KTM-WEBSRV01-ip

Then click on Next: Management button.

5. In the Create a virtual machine page, select the following values in the Management tab and then click on Next: Guest config button.

6. In the Create a virtual machine page, in the Guest config tab, click on Next: Tags button.

7. In the Create a virtual machine page, type or select the following values in the Tag tab:

  • NAME: Type Name
  • VALUE: KTM-WEBSRV01
  • RESOURCE: select Virtual machine

      Then click on Next: Review+ create button.

8. In the Create a virtual machine page, select the Review + create tab. Review the settings, and then click on Create button.

9. On the Create VM overview page, you will get …. Your deployment is underway.

10. After few minutes, you will get “Your deployment is complete” screen. Click on Go to resource button

11. In the Availability set overview page, value 1 is displayed under Virtual machines. Verify that virtual machines status is running, and showing Fault domain (0) and Updates domain (0).

Follow the all these steps for second VM name KTM-WEBSRV02, with a Public IP, and all the other settings the same as KTM-WEBSRV01.

In the Availability set overview page, now value 2 is displayed under Virtual machines.

Connect to KTM-WEBSRV01 using SSH:

In the Azure Portal, on the Overview page for Virtual machine, copy the Public IP address under Public IP address.

Installing and configuring Apache

Modify the Apache2 Ubuntu Default page:

In the Azure Portal, on the Overview page for Virtual machine, KTM-WEBSRV01 copy the Public IP address under Public IP address.

Open the web browser and paste the KTM-WEBSRV01 Public IP address and press enter.

Follow the same steps on a second server KTM-WEBSRV02.

Open the web browser and paste the KTM-WEBSRV02 Public IP address and press enter.

Related Post  Extend Azure Virtual Machine OS drive using Azure Portal

Configure Azure Load Balancer:
According to Microsoft definition, “Azure load balancer is a layer 4 load balancer that distributes incoming traffic among healthy virtual machine instances. Load balancers use a hash-based distribution algorithm. By default, it uses a 5-tuple (source IP, source port, destination IP, destination port, protocol type) hash to map traffic to available servers. Load balancers can either be internet-facing where it is accessible via public IP addresses or internal where it is only accessible from a virtual network. Azure load balancers also support Network Address Translation (NAT) to route traffic between public and private IP addresses.”

You can configure the load balancer to:

  • Load balance incoming traffic across your virtual machines.
  • Forward traffic to and from a specific virtual machine using NAT rules.

1. In the Azure Portal, click on +Create a resource, select Networking and then select the Load Balancer.

2. On the Create load balancer page, type or select the following values:

  • Name: Type MSSERVERPRO-LB
  • Type: Select Public
  • SKU: Select Basic
  • Public IP address: Select Create new.
    • Public IP Address field: Type MSPLB-PIP
    • Configure Public IP address > Assignment: Select Dynamic
  • Resource group: Select existing MSSERVERPRO-ASA-RG01
  • Location: Select Southeast Asia

      Then click on Create button.

3. On the Deployment succeeded box, click on Go to resource.

4. When the Load balancer is deployed, navigate to it the Azure Portal, Select Load balancers on the left menu, and double-click on LB name, MSSERVERPRO-LB.

5. In the Azure Portal, on the Overview page, Load balancer Dashboard page has opened. Under Settings, you have to configure Frontend IP Configuration, Backend pools, Health probes and Load Balancing rules.

6. Under Settings, select Frontend IP configuration, you do not have to do anything. Frontend IP address serve as ingress for the traffic.

7. Under Settings, select Backend pools, and then select Add button. Backend pool associated with the virtual machine Network Interface Card (NIC) to which load will be distributed.

8. On the Add a Backend pools page, type or select the following values

  • Name: Type Backendpool
  • Associated to : Drop down and select Availability set
  • Availability set: Select MSSERVERPRO-AS

        Then click on +Add a target network IP configuration

9. Select the VM from the Target virtual machine dropdown, and select the Network IP configuration for the VM from the Network IP configuration dropdown. Again, click on +Add a target network IP configuration.

10. Again Select the VM from the Target virtual machine drop-down, and select the Network IP configuration for the VM from the Network IP configuration drop-down. Then click on OK.

Related Post  Configuring Azure Traffic Manager using Performance Based Routing Method

11. On the Backend pools page, expand Backendpool and make sure that both 2 VMs are listed.

Create a Load Balancer Health Probe:

Load balancer health probe allows the load balancer to monitor VM status. So, health probe dynamically adds or removes VMs from the load balancer rotation based on their response to health checks.

To create a health probe to monitor the health of the VMs:
1. Under Settings, select Health probes, and then click on Add button.

2. On the Add a health probe page, type or select the following values:

  • Name: Type healthprobe
  • Protocol: Drop down and select HTTP
  • Port: Type 80
  • Path: Type /health.html
  • Interval: 5
  • Unhealthy threshold: 2

Then click on OK button.

3. Under Settings, select Health probes, verify that healthprobe rule has created.

Create an Azure Load Balancing Rules:

A load balancer rule defines how traffic is distributed to the VMs. The rule defines the front-end IP configuration for incoming traffic, the back-end IP pool to receive the traffic, required source and destination ports, health probe, session persistence, idle timeout and floating IP (direct server return).

1. On the Load Balancer Dashboard, under Settings, select Load balancing rules, and then click on Add button.

2. On the Add load balancing rule page, type or select the following values:

  • Name: Type LB-Rule
  • Frontend IP address: Select LoadBalancerFrontend
  • Protocol: Select TCP
  • Port: Type 80
  • Backend port: Type 80
  • Backend pool: Select Backendpool
  • Health probe: Select healthprobe

Then click on OK button.

3. Verify that Load balancing rules has created.

Test the Load balancer:

In the Azure Portal, on the Overview page of MSSERVERPRO-LB, copy the Public IP address under Public IP address.

Go to the web browser, paste the MSSERVEROR-LB Public IP address and press enter.

Hit Refresh, you can get result from second server.

Check the health probe.

Clean up resources:

Clean up the all related resources when you no longer need them.

Summary:

I hope this article helps in configuring an availability set, launch Ubuntu VMs instance with Apache2 installed with modify Apache Ubuntu Default page, add VMs to availability set, create Load Balancer and lastly how to combine a Load Balancer with availability set to get the Apache2 application resiliency.


3 comments

Leave a Reply

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