Virtual machines in Azure

Syed Sohaib Uddin
8 min readMay 16, 2020

Ever borrowed your friend’s laptop for doing a project that was too mainstream for yours? Need a GPU, improved storage, better clock speed with an advanced processor? What if I told you, a genie could fix your problems in a jiffy? Say hi to genie Azure.

The computing demands are always increasing. Be it a college project or an enterprise one, every developer is greedy when it comes to specs. Computing power is the new thing to flex about. High-end computers have huge price tags with them. Buying one certainly is no loss but when the requirements are crucial and short-lived, there is a lot to think about. Cloud providers felt the urgent need to address this problem and in a short time, we had virtual machines.

What is a Virtual Machine?

A virtual machine is a remote computer configured to your needs on-demand in a very short time. It is offered as an IaaS and just like a physical computer, you can run software and applications on a VM. The flexibility of hardware virtualization if offered via VM i.e you just have to configure the VM and then update, maintain it. It is allocated within minutes and provides diverse OS configurations, memory sizes, versions, disks sizes and processors to choose from.

VMs are an ideal choice when you need:

  • Total control over the operating system (OS)
  • The ability to run custom software, or
  • To use custom hosting configurations

How do VMs work?

Virtual machines are built on the concept of hardware virtualization.

Hardware virtualization

In our computers, the hardware and the OS are coupled together. Hardware virtualization is the ability of the OS to run without being bound to specific hardware. By this idea whenever you fire a VM, your custom configured OS is configured onto any hardware or infrastructure available. The hypervisor provides the abstraction between the OS and the underlying hardware needed to run VMs.

Hypervisor and VM Allocation process

Azure separates the computer hardware from its software using an intermediate abstraction layer called a hypervisor. This technique is referred to as virtualization. The hypervisor can simulate all the computer functions.

At Azure datacentres across the globe, each server includes a hypervisor. This allows us to run machines of different OS configurations to run on the same hardware. Racks of servers are connected via network switches. Each rack includes one server working as a fabric controller which is connected to the orchestrator. An orchestrator manages the entire system with respect to user requests that the Azure API fetches from the Azure portal. Once a user makes a request, it goes via the orchestrator to a fabric controller which then allocates a virtual machine.

VM allocation

If you live in India, you can be allocated a VM in the US. Yet, the process work perfectly and takes no time. Cloud computing provides us resources that we could only hope to use without upfront costs.

However, always going down to configuring a new VM whenever needed is a daunting task. Hence, Azure provides pre-configured VM images to choose from the Azure marketplace.

VM images

An image source can be an existing Azure VM that is either generalized or specialized, a managed image, a snapshot, or an image version in another image gallery. It is pre-configured via various providers to meet the requirements of a few popular and conventionally used OS setup.

Image definitions are created within an Image gallery and carry information about the image and requirements for using it internally. This includes whether the image is Windows or Linux, release notes, and minimum and maximum memory requirements. It is a definition of a type of image.

Whenever you want to fire a VM, you basically choose from an existing VM image as below.

VMs in Azure

Azure provides 6 types of virtual machines.

  • General-purpose: General purpose VMs provide a balanced CPU-to-memory ratio. They are ideal for testing and development, small to medium databases and low to medium traffic web servers.
  • Compute-optimized: These are high CPU-to-memory ratio and good for medium traffic web servers, network appliances, batch processes, and application servers.
  • Memory-optimized: As the name suggests, these VMs provide a high memory-to-CPU ratio and are great for relational database servers, medium to large caches, and in-memory analytics.
  • Storage-optimized: Storage optimized VMs have high disk throughput and IO ideal for Big Data, SQL, NoSQL databases, data warehousing and large transactional databases.
  • GPU: These are specialized virtual machines targeted for heavy graphic rendering and video editing, as well as model training and inferencing (ND) with deep learning. They are available with single or multiple GPUs.
  • High performance compute: It is the fastest and most powerful CPU virtual machines with optional high-throughput network interfaces (RDMA).

Depending on your requirements, you can very easily configure and fire up a VM. On the other hand, the entire process is complex and requires more than just a ‘click’ to allocate a piece of hardware over the internet.

Managing your VM

Depending on your requirements, you may configure multiple VMs. Hence, managing each of them effectively is important specially when you have your enterprise applications running on them.

The only events where you may experience a downtime are either during a planned Maintainance by the provider or a hardware failure. Both of which can be dealt with Availability sets.

Availability sets

An availability set is nothing but a logical grouping of multiple VMs that help keep the application available during maintenance.

When the VM is part of an availability set, the Azure fabric updates are sequenced so not all of the associated VMs are rebooted at the same time. VMs are put into different update domains. Update domains indicate groups of VMs and underlying physical hardware that can be rebooted at the same time. Update domains are a logical part of each data center and are implemented with software and logic. The group of virtual machines that share common hardware are in the same fault domain. A fault domain is essentially a rack of servers.

VMs can be placed across fault domains and update domains depending on the need and function of applications run on them by the user.

Firing a VM

Without any further a due, let’s create a VM in Azure using the Azure portal. However, Azure cloud shell, your PowerShell and Azure CLI can also be used.

Sign in to Azure

  1. Visit portal.azure.com and log in.
  2. If you do not have an account, create a free account before you login.

Creating a virtual machine

  1. In the search bar, type Virtual Machines.
  2. On the Virtual machines page, click add.
  3. Choose your appropriate subscription and then create new resource group.

4. Give your VM an appropriate name. Try to keep the resource group the same name as the VM.

5. Choose your region. This matters as long as you would be getting heavy traffic via hosting an application, if any, to the VM.

6. Choose a VM image. Images are pre-configured VM templates in the Azure marketplace. They have an OS by default.

7. Choose the appropriate size for your VM. Click on change size and use the filters to get what you need.

8. Setup the administrator account by entering a valid Username and Password. These credentials will always be required while accessing the VM.

9. Select the ports through which you want to establish connections with other IP addresses.

10. Leave everything else to default and directly move to the review+create tab and create the VM.

11. On successful allocation, you will receive a notification at the menu bar.

Connecting to your VM

  1. Type the name of your VM into the search bar. Navigate to the resource page.
  2. There are multiple ways to connect to your VM. We will connect via RDP using the Public IP address provided. But first, make sure you start your VM.

3. Open RDP on your machine and type in the public IP address and click on connect.

4. Type in your user name and password. Start working with your VM.

Alternately

  1. Download the Azure app from Playstore or App store.
  2. Log in with your credentials.
  3. Select virtual machines from your home page and click to launch.

4. Access the VM via RDP directly without having to navigate to the portal. 😉

Note: If you configure a Linux VM image, you must access it via ssh. To know how to set up an RDP connection for your Linux VM read my blog here.

Cleanup

  • Make sure you stop your VM once your session is over.
  • If VM is no longer required, delete the resource.

Summary

In this blog, we have learned about virtual machines, their types, uses, allocation process, management and usage.

Further Learning

VMs in Azure — https://azure.microsoft.com/en-us/services/virtual-machines/

--

--