Virtual Machines
Azure Virtual Machines (VMs) give you full control over operating systems, custom software, and infrastructure — the classic IaaS building block.
Simple Explanation
A Virtual Machine is a computer running inside Microsoft's data center. You choose the OS, size, and software. Azure manages the physical hardware for you.
When to Use VMs
- Legacy applications that require specific OS versions or drivers.
- Lift-and-shift migrations where rewriting is not yet feasible.
- Workloads needing full OS-level control (custom kernel, agents, tools).
- Stateful apps that cannot run on PaaS without significant rework.
If your workload is a web app, API, or event-driven function — App Services or Azure Functions are faster to deploy, cheaper to operate, and automatically patched. Consider VMs only when PaaS is not an option.
VM Sizes
Azure VM sizes are grouped by purpose. Always right-size from the start — you can resize later but it causes a brief restart.
| Series | Purpose | Common SKU Examples |
|---|---|---|
| B-series | Burstable, low steady-state. Dev/test, light workloads. | Standard_B2s, B4ms |
| D-series | General-purpose balanced CPU/memory. Most web apps, app servers. | Standard_D2s_v3, D4s_v3 |
| E-series | Memory-optimized. In-memory databases, caches. | Standard_E4s_v3, E8s_v3 |
| F-series | Compute-optimized. High-CPU workloads, game servers. | Standard_F2s_v2 |
| N-series | GPU-equipped. ML training, rendering. | Standard_NC6s_v3 |
Disk Types
| Disk Type | Best For | Max IOPS |
|---|---|---|
| Standard HDD | Dev/test, infrequent access, archiving | Up to 500 |
| Standard SSD | Web servers, lightly loaded DBs | Up to 6,000 |
| Premium SSD | Production workloads, databases, I/O-intensive | Up to 20,000 |
| Ultra Disk | SAP HANA, top-tier SQL, real-time analytics | Up to 160,000 |
Visual Representation
Commands
# Create a resource group az group create --name rg-web-dev --location eastus # Create a VM (Ubuntu, Standard_B2s) az vm create \ --resource-group rg-web-dev \ --name vm-web-01 \ --image Ubuntu2204 \ --size Standard_B2s \ --admin-username azureuser \ --generate-ssh-keys # Open port 80 az vm open-port --resource-group rg-web-dev --name vm-web-01 --port 80 # List VMs az vm list --output table # Get public IP az vm show --resource-group rg-web-dev --name vm-web-01 \ --query publicIps --output tsv # Start / Stop / Deallocate az vm start --resource-group rg-web-dev --name vm-web-01 az vm stop --resource-group rg-web-dev --name vm-web-01 az vm deallocate --resource-group rg-web-dev --name vm-web-01 # Resize az vm resize --resource-group rg-web-dev --name vm-web-01 --size Standard_D2s_v3
Hands-on
- Create a resource group in your nearest region.
- Deploy a Standard_B2s Ubuntu VM using CLI or Portal.
- Connect via SSH (
ssh azureuser@<public-ip>). - Install nginx:
sudo apt install -y nginxand verify via browser. - Deallocate the VM to stop billing; note the difference from Stop.
Debugging Scenario
Issue: VM is unresponsive after OS update.
- Check Boot Diagnostics in Portal → VM → Boot diagnostics → Screenshot.
- Try Serial Console for emergency shell access without network.
- If disk issue: detach OS disk, attach to recovery VM, fix, re-attach.
- Check Activity Log for any unexpected operations that preceded the issue.
Interview Questions
Beginner
An IaaS service providing configurable virtual computers in Azure data centers. You manage the OS and software; Azure manages the hardware.
Stop keeps the VM allocated (still billed for compute). Deallocate releases the compute resources and stops billing for the VM SKU.
A storage disk managed by Azure where you don't manage the underlying storage account. Azure handles replication, snapshots, and SLA.
Intermediate
When running production databases or I/O-intensive apps that need consistent low-latency and high IOPS. Standard SSD is sufficient for web servers and lightly loaded apps.
Single instance with Premium SSD gets 99.9% SLA. Two VMs in an availability set get 99.95%. VMs across availability zones get 99.99%.
Scenario-based
Azure VM with the required Windows version. IaaS is the right model for software that cannot be abstracted away from OS-level dependencies.
Check Boot Diagnostics → screenshot. Use Serial Console for emergency recovery. If kernel issue, attach disk to recovery VM, repair bootloader, re-attach.
Real-world Usage
Most enterprises run VMs for legacy apps, domain controllers, and SQL Server instances requiring specific features not available in PaaS. New greenfield workloads increasingly move to App Services or containers.
Summary
VMs are the most flexible Azure compute option but carry the highest operational burden. Use them when PaaS options genuinely cannot satisfy the requirement. Right-size with B-series for dev/test and D-series for production apps.