Module 2 Beginner to Intermediate AZ-104 AZ-900 20 min read

Azure Virtual Machines

Azure Virtual Machines (VMs) are one of the most fundamental and widely used services in Azure. Learn everything from what a VM is, how to create one, choose the right size, connect to it, manage it, and keep costs under control — with real world examples throughout.

What you'll learn: What Azure VMs are · VM series & sizes · Operating systems supported · How to create a VM step by step · Connecting to a VM · VM disks & storage · Availability options · Pricing & cost saving · Best practices · Real world use cases · AZ-104 exam tips
In this tutorial
What is an Azure Virtual Machine?
VM series and sizes
Supported operating systems
Creating a VM — step by step
Connecting to your VM
VM disks and storage
Availability options
VM pricing and cost saving tips
Real world use cases
Best practices
AZ-104 exam tips

What is an Azure Virtual Machine?

An Azure Virtual Machine (VM) is a software-based computer that runs on Microsoft's physical servers in Azure datacenters. It behaves exactly like a real computer — it has a CPU, RAM, storage, and a network connection — but it exists entirely in the cloud.

When you create a VM in Azure, you're essentially renting a portion of a physical server. You get full control over the operating system, installed software, and configuration — just like owning a physical machine, but without the hardware costs or maintenance burden.

Azure VMs are an example of Infrastructure as a Service (IaaS) — Microsoft manages the physical hardware, network, and datacenter, while you manage everything from the operating system upwards.

💡 Real world analogy: Think of Azure VMs like renting a fully furnished apartment. The building (physical server) and utilities (power, cooling, network) are managed by Microsoft. You get the keys (admin access) and decide how to furnish and use the space (OS, software, configuration).

VM series and sizes

Azure offers hundreds of VM sizes organised into series, each optimised for different workloads. Choosing the right size is critical — too small and your app runs slowly, too large and you waste money.

1
B-series (Burstable) — Best for workloads with low baseline CPU usage that occasionally need to burst. Most cost-effective for development, testing, and small web servers.
Example: B1s (1 vCPU, 1 GB RAM) — Free for 12 months on Azure free account
2
D-series (General Purpose) — Balanced CPU to memory ratio. Ideal for most production workloads — web servers, application servers, small to medium databases.
Example: D2s v5 (2 vCPU, 8 GB RAM) — Most popular for general workloads
3
E-series (Memory Optimised) — High memory to CPU ratio. Best for in-memory databases, large caches, and data analytics workloads.
Example: E4s v5 (4 vCPU, 32 GB RAM)
4
F-series (Compute Optimised) — High CPU to memory ratio. Best for batch processing, web servers with high traffic, and gaming servers.
Example: F4s v2 (4 vCPU, 8 GB RAM)
5
N-series (GPU) — Equipped with NVIDIA GPUs. Best for AI/ML model training, video rendering, and high-performance computing.
Example: NC6s v3 (6 vCPU, 112 GB RAM, 1 GPU)
6
L-series (Storage Optimised) — High disk throughput and I/O. Best for big data, SQL, NoSQL databases, and data warehousing.
Example: L8s v3 (8 vCPU, 64 GB RAM, high NVMe storage)
# List all available VM sizes in Central India region
az vm list-sizes \
  --location centralindia \
  --output table

# Output example:
Name NumberOfCores MemoryInMb OsDiskSizeInMb
Standard_B1s 1 1024 1047552
Standard_B2s 2 4096 1047552
Standard_D2s_v5 2 8192 1047552

Supported operating systems

One of Azure's biggest strengths is support for both Windows and Linux operating systems — unlike traditional on-premises environments that were often Windows-only.

1
Windows — Windows Server 2019, 2022, Windows 10, Windows 11. Best for .NET applications, Active Directory, SQL Server, and enterprise workloads.
2
Linux — Ubuntu — Most popular Linux distribution on Azure. Available in 20.04 LTS, 22.04 LTS, and 24.04 LTS. Best for web servers, containers, and open-source workloads.
3
Linux — Red Hat Enterprise Linux (RHEL) — Enterprise-grade Linux. Popular in large organisations and financial institutions.
4
Linux — CentOS, Debian, SUSE — Additional Linux distributions available in the Azure Marketplace for specific use cases.
💡 Tip: For learning and most web workloads, choose Ubuntu 22.04 LTS — it's free, widely supported, has excellent documentation, and is the most popular Linux OS on Azure.

Creating a VM — step by step

Let's create a real Azure Virtual Machine together. We'll create a small Ubuntu VM in Central India — perfect for learning and testing.

1
Go to portal.azure.com and search for "Virtual Machines" in the top search bar. Click on it.
2
Click "+ Create" → Select "Azure virtual machine"
3
Basics tab — Project details:
• Subscription: Your subscription
• Resource Group: Create new → rkc-vm-rg
4
Basics tab — Instance details:
• Virtual machine name: rkc-ubuntu-vm
• Region: Central India
• Availability options: No infrastructure redundancy (for learning)
• Security type: Standard
• Image: Ubuntu Server 22.04 LTS
• Size: Standard_B1s (free tier eligible)
5
Basics tab — Administrator account:
• Authentication type: SSH public key (recommended) or Password
• Username: azureuser
• For learning: choose Password and set a strong password
6
Basics tab — Inbound port rules:
• Public inbound ports: Allow selected ports
• Select inbound ports: SSH (22) for Linux
7
Disks tab:
• OS disk type: Standard SSD (good balance of cost and performance)
• Leave other settings as default
8
Networking tab:
• Azure automatically creates a Virtual Network, Subnet, and Public IP
• Leave defaults for learning purposes
9
Management tab:
• Enable Auto-shutdown — set to 7:00 PM IST to avoid overnight charges! This is very important for cost control.
10
Click "Review + Create" → Review the summary → Click "Create"
Deployment takes 2–3 minutes. Watch the notifications bell for progress!
Azure CLI — Create the same VM in one command
# Create a VM using Azure CLI
az vm create \
  --resource-group rkc-vm-rg \
  --name rkc-ubuntu-vm \
  --image Ubuntu2204 \
  --size Standard_B1s \
  --location centralindia \
  --admin-username azureuser \
  --generate-ssh-keys

# Output shows public IP address once created
{ "publicIpAddress": "20.xx.xx.xx", "powerState": "VM running" }

Connecting to your VM

1
Connect to Linux VM via SSH:
Open terminal or Command Prompt and run:
ssh azureuser@YOUR_PUBLIC_IP
Enter your password when prompted. You're now inside your VM!
2
Connect to Windows VM via RDP:
• In Azure Portal → your VM → Click "Connect""RDP"
• Download the RDP file
• Open it → enter your username and password
• You'll see the Windows desktop of your cloud VM!
3
Connect via Azure Bastion (Most Secure):
Azure Bastion lets you connect to VMs directly from the browser without exposing SSH/RDP ports to the internet. Recommended for production environments.
SSH connection example
# Connect to your Linux VM via SSH
ssh azureuser@20.xx.xx.xx

# Once connected — you'll see:
azureuser@rkc-ubuntu-vm:~$

# Run some basic commands to explore
uname -a # Check OS version
df -h # Check disk space
free -h # Check memory usage

VM disks and storage

Every Azure VM has at least one disk — the OS disk. You can attach additional data disks as needed.

1
OS Disk — Contains the operating system. Created automatically when you create a VM. Cannot be detached while the VM is running.
2
Data Disk — Additional disks you attach for storing application data, databases, or files. Can be attached and detached without deleting the VM.
3
Temporary Disk — A small, fast disk included with most VMs. Data is lost when the VM is stopped or restarted! Only use for temporary files like page files or swap space.
4
Disk types:
Ultra Disk — Highest performance, for mission-critical databases
Premium SSD v2 — High performance, flexible sizing
Premium SSD — Production workloads
Standard SSD — Web servers, lightly used apps
Standard HDD — Backups, non-critical workloads (cheapest)

Availability options

For production workloads, you need to protect your VM from hardware failures and planned maintenance. Azure offers several options:

1
Availability Zones — Deploy VMs across physically separate datacenters within the same region. Protects against datacenter-level failures. Azure guarantees 99.99% uptime SLA for VMs across zones.
2
Availability Sets — Groups VMs across different physical servers, racks, and storage within a datacenter. Protects against hardware failures and rack-level issues. Azure guarantees 99.95% uptime SLA.
3
Virtual Machine Scale Sets (VMSS) — Automatically creates and manages a group of identical VMs. Scales in or out based on demand. Perfect for applications with variable traffic.

VM pricing and cost saving tips

Azure VM pricing depends on the VM size, OS, region, and how long it runs. Here are the most important cost saving strategies:

1
Enable Auto-shutdown — Set VMs to automatically shut down at night. A VM running 8 hours/day costs 66% less than one running 24/7.
2
Use Reserved Instances — Commit to 1 or 3 years and save up to 72% compared to pay-as-you-go pricing.
3
Use Spot VMs — Use unused Azure capacity at up to 90% discount. Ideal for batch jobs, dev/test, and fault-tolerant workloads.
4
Right-size your VMs — Use Azure Advisor recommendations to identify over-provisioned VMs and downsize them to save cost.
5
Azure Hybrid Benefit — Already have Windows Server or SQL Server licences? Use them on Azure and save up to 40%.
6
Delete vs Deallocate — When you stop (deallocate) a VM, you stop compute charges but still pay for storage. When you delete the VM entirely, all charges stop.
Azure CLI — Start, stop and deallocate VMs
# Stop and deallocate a VM (stops compute charges)
az vm deallocate \
  --resource-group rkc-vm-rg \
  --name rkc-ubuntu-vm

# Start a VM
az vm start \
  --resource-group rkc-vm-rg \
  --name rkc-ubuntu-vm

# Check VM status
az vm get-instance-view \
  --resource-group rkc-vm-rg \
  --name rkc-ubuntu-vm \
  --query "instanceView.statuses[1].displayStatus"

Real world use cases

1
Web server hosting — Host websites and web applications on Linux VMs running Nginx or Apache. Common for companies migrating from on-premises servers.
2
Development & testing — Create isolated VMs for developers to test applications without affecting production. Spin up and delete as needed.
3
Database servers — Run SQL Server, MySQL, PostgreSQL, or Oracle on VMs when you need full control over the database configuration.
4
Lift and shift migration — Move existing on-premises servers to Azure VMs without changing the application. The fastest way to get to the cloud.
5
SAP workloads — Microsoft and SAP have a deep partnership. Many enterprises run SAP HANA on Azure VMs for ERP systems.

Best practices

1
Always use SSH keys instead of passwords for Linux VMs — they are significantly more secure and harder to brute-force.
2
Never expose RDP (port 3389) or SSH (port 22) directly to the internet in production. Use Azure Bastion or VPN instead.
3
Always tag your VMs — Add tags like Environment: Production, Owner: YourName, CostCenter: IT. Makes cost tracking and management much easier.
4
Enable Azure Backup for production VMs — Protects against accidental deletion, ransomware, and data corruption.
5
Keep OS updated — Enable automatic OS updates or regularly patch VMs to protect against security vulnerabilities.
6
Monitor VM performance — Enable Azure Monitor and set alerts for high CPU, memory, or disk usage to catch issues before they become problems.

AZ-104 exam tips

✅ Know the difference between Stop (deallocate) and Delete — deallocate stops compute charges but storage charges continue
✅ Understand VM Availability Sets vs Availability Zones — Sets protect within a datacenter, Zones protect across datacenters
✅ Know that Temporary disk data is lost when VM is stopped or restarted
✅ Remember Azure Bastion provides secure browser-based VM access without public IP
✅ Understand VM Scale Sets for automatic scaling
✅ Know that Reserved Instances save up to 72% vs pay-as-you-go
✅ Remember VM SLAs — 99.99% for Availability Zones, 99.95% for Availability Sets, 99.9% for single VM with Premium SSD