Skip to content

You are viewing a free preview of this lesson.

Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.

Introduction to Azure Virtual Machines

Introduction to Azure Virtual Machines

Azure Virtual Machines (VMs) are one of the most widely used services on Microsoft Azure. They provide on-demand, scalable computing resources in the cloud and give you the flexibility of virtualisation without having to buy and maintain physical hardware.


What is a Virtual Machine?

A virtual machine is an emulation of a physical computer. It runs an operating system and applications just like a physical server, but it exists as software within Azure's data centres. Each VM has virtual hardware — including CPU, memory, storage, and networking — allocated from the underlying physical host.

Key Characteristics

Characteristic Description
On-demand Create and delete VMs in minutes
Scalable Start small and scale up (or out) as needed
Pay-per-use Charged by the second when running
Full control You manage the OS, patches, and applications
IaaS Infrastructure as a Service — Azure manages the physical infrastructure, you manage everything above the hypervisor

When to Use Azure VMs

Virtual machines are ideal when you need full control over the computing environment. Common scenarios include:

Lift and Shift Migration

Migrating existing on-premises workloads to the cloud with minimal changes. If you have a Windows Server running IIS or a Linux server running Apache, you can recreate the same environment as an Azure VM.

Development and Testing

Quickly spin up environments for development, testing, or CI/CD pipelines. Developers can create VMs that mirror production configurations without affecting live systems. When testing is complete, delete the VM and stop paying.

Running Enterprise Applications

Many enterprise applications — such as SAP, Oracle Database, SQL Server, and custom line-of-business apps — run on Azure VMs. These applications often require specific OS configurations or kernel-level access that PaaS services cannot provide.

High-Performance Computing (HPC)

Azure offers specialised VM sizes with high-speed networking (InfiniBand) and GPU acceleration for scientific simulations, rendering, and machine learning training workloads.

Disaster Recovery

Use Azure VMs as a disaster recovery target for on-premises servers. Azure Site Recovery automates replication and failover, keeping recovery time objectives low.


Creating Your First VM

You can create a VM using the Azure Portal, Azure CLI, PowerShell, ARM templates, Bicep, or Terraform. Here is a simple example using the Azure CLI:

# Create a resource group
az group create --name rg-vm-demo --location uksouth

# Create a Linux VM
az vm create \
  --resource-group rg-vm-demo \
  --name myLinuxVM \
  --image Ubuntu2204 \
  --size Standard_B2s \
  --admin-username azureuser \
  --generate-ssh-keys

This command creates:

  • A virtual machine with Ubuntu 22.04
  • A B2s size (2 vCPUs, 4 GiB RAM — burstable)
  • An SSH key pair for authentication
  • A virtual network, subnet, public IP, and network security group (all created automatically)

Creating a Windows VM

az vm create \
  --resource-group rg-vm-demo \
  --name myWindowsVM \
  --image Win2022Datacenter \
  --size Standard_D2s_v5 \
  --admin-username azureuser \
  --admin-password 'YourSecurePassword123!'

Components of an Azure VM

When you create a VM, several Azure resources are provisioned together:

Resource Purpose
Virtual Machine The compute instance itself
OS Disk Managed disk containing the operating system
Data Disks Optional additional managed disks for application data
Network Interface (NIC) Connects the VM to a virtual network
Virtual Network & Subnet The private network the VM resides in
Public IP Address Optional — provides internet-accessible IP
Network Security Group (NSG) Firewall rules controlling inbound/outbound traffic

Understanding these components is crucial because each is an independent Azure resource with its own lifecycle, cost, and configuration.


VM States and Billing

Azure VMs can be in several states, and billing depends on which state the VM is in:

State Compute Charges Storage Charges
Running Yes Yes
Stopped (from OS) Yes — the VM is still allocated on the host Yes
Stopped (Deallocated) No Yes (disks still exist)
Deleted No No (if disks are also deleted)

Important: Shutting down a VM from within the operating system (e.g., sudo shutdown) does not deallocate it. You must use the Azure Portal, CLI, or API to deallocate and stop billing for compute:

# Deallocate a VM (stops compute charges)
az vm deallocate --resource-group rg-vm-demo --name myLinuxVM

Connecting to a VM

Linux VMs — SSH

ssh azureuser@<public-ip>

Windows VMs — RDP

Use Remote Desktop Protocol (RDP) to connect via port 3389. Download the RDP file from the Azure Portal.

Azure Bastion

For secure access without exposing public IPs, use Azure Bastion. It provides browser-based SSH and RDP through the Azure Portal over TLS, eliminating the need for a public IP on the VM.


Supported Operating Systems

Azure supports a wide range of operating systems:

Linux: Ubuntu, Red Hat Enterprise Linux, SUSE Linux Enterprise, Debian, CentOS, Oracle Linux, Flatcar Container Linux, and many more.

Windows: Windows Server 2012 R2 through Windows Server 2025, Windows 10, Windows 11 (for virtual desktops).

Azure also supports custom images, so you can bring your own pre-configured OS image.


Summary

Azure Virtual Machines provide full infrastructure-level control in the cloud. They support both Windows and Linux, can be created in minutes, and are billed per second. Understanding VM states is essential to managing costs — always deallocate VMs you're not using rather than just shutting them down from the OS. In the next lesson, we'll explore the different VM sizes and series to help you choose the right configuration for your workload.