In this project, I will show you how to create and link the following resources on the Azure cloud platform.
- Provision an Azure virtual machine with an Ubuntu OS image.
- Availability sets
- Install Apache webserver on the Azure virtual machine (Cloud Init).
- Load Balancer
To carry out a reproduction of the same projects in this task, you can create an Azure account and have access to myriads of resources to play with. (Note : This is not an affiliate or sponsored ad for Azure.)
1 Provision an Azure virtual machine with an Ubuntu OS image
From the Azure home portal, locate and click the all resources button to see all the available resources you can work with on your subscription.
Better still, we can always search for the resource by name in the global search bar (e.g., searching for virtual machines will bring out the virtual machine resource).
An Azure virtual machine gives you the flexibility of virtualization without having to buy and maintain the physical hardware that runs it. However, you still need to maintain the virtual machine by performing tasks, such as configuring, patching, and installing the software that runs on it.
For more information on Azure Virtual machines: https://learn.microsoft.com/en-us/azure/virtual-machines/overview
Click on the create virtual machines button to launch the creation process for Azure Virtual Machines.
(IMAGE 2)
2 Availability Set
An Availability Set is a logical grouping capability for isolating VM resources from each other when they're deployed. Azure makes sure that if a hardware or software failure happens, only a subset of your VMs are impacted and your overall solution stays operational. Availability sets are essential for building reliable cloud solutions. For more information,see: https://learn.microsoft.com/en-us/azure/virtual-machines/availability#virtual-machines-scale-sets
For example, in a house we have rooms 1 & 2; when you deploy your virtual machines into an availability set, Azure deploys the virtual machines into separate houses, such that if there is a disaster in room 1, it won't have an effect on room 2. The two rooms will only be down at the same time when the house (room 1 & room 2) is impacted by the disaster.
There are various availability options to help with disaster recovery on Azure: https://learn.microsoft.com/en-us/azure/virtual-machines/availability
We can create an availability set as a stand-alone resource and attach and assign our virtual machines to the created availability sets. However, in this project, the availability sets will be created during the virtual machine instance creation (refer to image 3, where we launched the virtual machine resources creation).In the availability options, you select the drop down menu and select the availability sets.
Click the "create new availability" button to create a new availability set.
(Image 5).
The virtual machine creation process continues. Virtual machine OS Image: The OS image determines what purpose the virtual machine serves. You can provision a virtual machine as a Windows desktop, a Windows server, or a Linux server with various Linux distributions. For more information, see: https://learn.microsoft.com/en-us/azure/virtual-machines/overview#distributions
In the Image tab, select See all images to see all the available images on the Azure marketplace. (For this project, we will be using the Ubuntu Server 20.04 LTS-Gen2)
(IMAGE 6)
VM SIZE: Determine the type of virtual machine we get and the operations that can be performed on it. For more information, see:
(IMAGE 7)
Clicking the "See all sizes" option for the Virtual Machine size option shows all the sizes available to select in your subscription.
(IMAGE 8)-You can filter the VM cost by using the top/down toggle button).
In another project, we will generate an SSH key for logging into a Linux server
In the public inbound ports, select the allowed ports. In the allowed inbound ports (HTTPS 80—this will allow users to access the webserver webpages; Port 22—to allow a user to log into the webserver). (This settings can be controlled from the Network security group)
(IMAGE 9)
For the selection of the virtual machine OS disks (for this project we will use a standard HDD ). Azure charges differently based on the type of disk you are using (Ultra Disk, Premium Disk, or Standard Disk ). For more information, see: https://learn.microsoft.com/en-us/azure/virtual-machines/disks-types
In the networking tab, we will use the virtual network (VNET) and subnet automatically created by the Azure wizard for this project (Note: we can also create the VNET and subnet as standalone resources, and add the VM to it).
This time we won't use the Azure wizard to automatically create a load balancer. We will create the load balancer as a stand-alone resource after completing the set up of the virtual machines and the availability sets.
(IMAGE 11)
3 ** **Install Apache webserver on the Azure virtual machine (Cloud Init).
For custom data & cloud init, we will use a bash script to set-up a webserver (apache) during the virtual machine. For more information on cloud init:
(IMAGE 12)
In the custom data box input this bash script. :
#!/bin/sh
sudo apt install apache2 -y
After the setup has been validated, create the VM.
(Image 13)
When the VM has successfully been created, with the created VM attached public IP (51.142.119.100) we created in the network wizard tab, do this to confirm if the Apache webserver was successfully launched.
(Note : Port 80 (HTTP) was opened during the VM creation process from Image so we can access the webserver over the internet. Access to and from the VM is configured in the Network security group tab of the networking section as shown in IMAGE 9.
(IMAGE 14)
We don't need a public IP for the VM, so we will disable the public IP currently attached to the VM. As we will be attaching a load balancer to the VM, the IP of the load balancer will sit in front of the virtual machines.
(IMAGE 15)
(Image 18) (Use the toggle button to disassociate from the Public IP)
We add another virtual machine to the same availability set as the first one.
(IMAGE 19)
In the networking tab we add the virtual machine to the same virtual network(VNET), as the first virtual machine. Make certain that it is provisioned in the same region and virtual network as the first virtual machine, if not you won't be able to add it to the basic load balancer.
(IMAGE 20) (We will disable the public IP from setup wizard this time)
(IMAGE 21) (the second virtual machine in the availability set.
You can confirm the availability setup of the virtual machine from the availability and scaling section.
(IMAGE 22)
4 *Load Balancer *
Load balancing refers to evenly distributing load (incoming network traffic) across a group of backend resources or servers.
Azure Load Balancer operates at layer 4 of the Open Systems Interconnection (OSI) model. It's the single point of contact for clients. Load balancer distributes inbound flows that arrive at the load balancer's front end to backend pool instances. These flows are according to configured load-balancing rules and health probes. The backend pool instances can be Azure Virtual Machines or instances in a virtual machine scale set.
For more information : https://learn.microsoft.com/en-us/azure/load-balancer/load-balancer-overview
You can locate the load balancer resources from all resources, or from the global search. (IMAGE 23)
We will be using Azure basic load balancer, SKU, as the public load balancer for this project since we intend to serve websites from the virtual machines. For more information on Azure load balancer SKUs, see: https://learn.microsoft.com/en-us/azure/load-balancer/skus#skus
We will add a public IP to the load balancer that will sit at the front of the availability set that has the virtual machines.
(IMAGE 25)
Next, we will add the virtual machines in the availability sets to the backend of the load-balancers.
(IMAGE 27)
Inbound RULE
Here we link the Frontend_IP_Configuration and Backend_Pool
Protocol: TCP, Port: 80 (to access the webserver content), BackendPort :80 (to the virtual machines)
(IMAGE 29)
HEALTH PROBE: Will monitor the health status of the virtual machines in the backend. This will determine if traffic will still be directed to the virtual machines.
(IMAGE 30)
After adding the inbound rules, we review and create
(IMAGE 27)
Checking the status of the virtual machines in the availability sets confirms that the load-balancers frontends IP configuration linked to the VM.
(IMAGE 29)
We confirm if the IP is still serving the default Apache web page.
Project completed; please leave your comments, feedback, and project suggestions for me to write about.
You can also read: How to add virtual machine to an existing availability-sets on Azure.
https://dev.to/cli_tayo/adding-a-virtual-machine-to-an-existing-availability-sets-on-azure-ahh
Top comments (0)