Lesson 09 — Virtual Machines: Configuration, Sizing & Availability

Domain 3 — Compute AZ-104: 20–25% ~40 min Prereq: Lesson 08 — Azure Files

Compute Is the Heart of the AZ-104 Exam

At 20–25% exam weight, the compute domain is the largest single domain in AZ-104. Virtual machines are where most Azure administrators spend the majority of their day: provisioning, resizing, configuring disks, managing availability, deploying extensions, and troubleshooting. The exam tests both theoretical knowledge (which SLA does an availability zone give you?) and operational judgment (when should you use a spot VM? what disk type for a database?)

This lesson covers every major VM concept you need: VM families, the disk ecosystem, the four availability layers, proximity placement groups, spot VMs, extensions, images, and hybrid licensing. Master this and you have locked in over a fifth of your exam score before the next domain.

VM Families and the Naming Convention

Azure has dozens of VM series, each optimised for a specific workload class. The AZ-104 exam does not require memorising every series, but you must know the major families and be able to decode the VM size naming convention.

FamilyOptimised ForExample SizesTypical Use Cases
D-series General purpose (balanced CPU/RAM) Standard_D4s_v5, Standard_D8as_v5 Web servers, app servers, small databases, dev/test
E-series Memory optimised (high RAM:vCPU ratio) Standard_E8s_v5, Standard_E64s_v5 In-memory databases (SAP HANA, Redis), large caches
F-series Compute optimised (high vCPU:RAM ratio) Standard_F4s_v2, Standard_F72s_v2 Batch processing, web frontends, game servers
L-series Storage optimised (high local NVMe throughput) Standard_L8s_v3, Standard_L80s_v3 NoSQL databases, Elasticsearch, data warehousing
N-series GPU compute and visualisation Standard_NC6s_v3, Standard_NV12s_v3 AI/ML training (NC), remote visualisation and rendering (NV)
B-series Burstable (CPU credit model) Standard_B2s, Standard_B4ms Dev/test, low-traffic web servers, small CI/CD agents

Decoding the VM Size Name

Understanding the naming convention is a practical skill and sometimes tested directly. The format is:

Standard_D4s_v5 Standard → Pricing tier (Standard = production; Basic = legacy, deprecated) D → VM family (D = general purpose) 4 → vCPU count s → Premium Storage capable (can use Premium SSD) _v5 → Version 5 of the D-series hardware generation

Additional letter modifiers you may encounter: a = AMD processor, d = local temp disk included, i = isolated (dedicated physical host), l = low memory variant, m = memory optimised variant within the family.

B-series burstable — CPU credits B-series VMs accumulate CPU credits when running below baseline CPU utilisation, and spend those credits when bursting above baseline. If a B-series VM exhausts its CPU credits, performance is throttled to baseline — which can be as low as 10–20% CPU. Never deploy latency-sensitive or always-busy production workloads on B-series.

VM Creation Components

Deploying a VM is not a single-resource operation. A VM deployment touches multiple Azure resources, each with its own lifecycle and configuration options:

  • OS Disk: Managed disk containing the operating system. Sourced from a marketplace image, a custom image, or an uploaded VHD. Type must be selected at creation (Standard HDD/SSD, Premium SSD v1/v2, Ultra).
  • Data Disks: Additional managed disks attached for application data. A VM can have multiple data disks (limit depends on VM size). Each has independently configurable disk type and caching.
  • NIC (Network Interface Card): Every VM has at least one NIC with a private IP in a VNet subnet. A public IP can be attached. NSGs can be associated at NIC or subnet level.
  • Admin Credentials: Windows VMs use username/password. Linux VMs should always use SSH key pairs — password authentication on Linux should be disabled.
  • Availability Configuration: Availability set, availability zone, or none. Must be configured at VM creation time — you cannot move a deployed VM into an availability set or change its zone later.
  • Extensions: Agents and scripts installed post-deployment for monitoring, encryption, configuration management.
Availability cannot be changed post-deployment You cannot add a VM to an availability set after it has been deployed, and you cannot change a VM's availability zone after deployment. If you make the wrong availability choice at creation time, you must delete and redeploy the VM. Plan this carefully before deployment — especially in IaC pipelines where this could trigger unintended downtime.

OS Image Types

Azure VMs are deployed from images. Understanding image types is important for VM fleet management at scale.

Image TypeDescriptionUse Case
Marketplace image Pre-built images from Microsoft and third-party publishers (Windows Server, Ubuntu, RHEL, SQL Server, etc.). Always up to date. Standard deployments where the base OS is sufficient
Custom image (generalised) Created by Sysprep-ing (Windows) or running waagent -deprovision (Linux) on a VM, then capturing it. All machine-specific data removed. Golden images with pre-installed software, custom configuration. Safe to deploy multiple VMs from.
Custom image (specialised) A snapshot of a VM without Sysprep/deprovision — retains machine identity, hostname, SIDs. Disaster recovery restore, one-off migrations. Not safe for multi-VM deployment.
Azure Compute Gallery image Versioned images stored in a gallery (formerly Shared Image Gallery). Can replicate across regions and share across subscriptions. Enterprise image management for large VM fleets

Azure Compute Gallery

The Azure Compute Gallery (formerly Shared Image Gallery) provides enterprise-grade image management:

  • Image definitions: Metadata container specifying OS type (Windows/Linux), publisher, offer, SKU, and generation (Gen1/Gen2).
  • Image versions: Actual image artifacts with version numbers (e.g. 1.0.0, 1.1.0). Each version can be replicated to multiple Azure regions for performance.
  • RBAC sharing: Share images with specific subscriptions, tenants, or make them publicly available.
  • Regional replication: Azure replicates image versions to chosen regions automatically, reducing deployment time for VM scale sets and large fleets.

Managed Disks

Always use managed disks. Unmanaged disks (page blobs stored in a customer-managed storage account) are a legacy concept — you have to manage the storage accounts yourself, availability set placement is limited, and Azure Backup integration is poor. Managed disks are standalone Azure resources with their own resource ID, independent lifecycle, and first-class Azure feature support.

Disk Types Compared

Disk TypeMediaIOPS (max)ThroughputLatencyBest For
Standard HDD HDD (magnetic) 500 IOPS/disk 60 MB/s High (ms) Dev/test, infrequently accessed data, backups
Standard SSD SSD 6,000 IOPS/disk 750 MB/s Medium Production workloads with moderate IOPS, web servers
Premium SSD v1 SSD (NVMe) Up to 20,000 IOPS/disk (P50) Up to 900 MB/s Low (single-digit ms) Production databases, enterprise apps; IOPS/throughput tied to disk size tier
Premium SSD v2 SSD (NVMe) Up to 80,000 IOPS/disk Up to 1,200 MB/s Sub-ms High-performance databases; IOPS/throughput configurable independently of size
Ultra Disk SSD (NVMe) Up to 160,000 IOPS/disk Up to 4,000 MB/s Sub-ms (<1 ms) Most demanding I/O: SQL Server, SAP HANA, Oracle. Must be in same AZ as VM.
Premium SSD v1 IOPS are size-tiered On Premium SSD v1, IOPS and throughput are determined by the disk size tier (P-series), not by what you pay independently. A P10 (128 GiB) gives 500 IOPS; a P30 (1 TiB) gives 5,000 IOPS. If you need more IOPS, you must provision a larger disk — even if you don't need the extra storage. Premium SSD v2 solves this by allowing you to set IOPS independently of size.
Ultra Disk constraints Ultra Disk is only available in specific regions and Availability Zones. The VM must be in the same Availability Zone as the Ultra Disk — which means Ultra Disk deployments always require AZ-aware placement. Ultra Disk also cannot be used as an OS disk (data disks only) and does not support snapshots or Azure Backup. Plan your architecture accordingly before committing to Ultra Disk.

Disk Caching

Each managed disk has a configurable caching mode, which determines how the host server's RAM and CPU are used to buffer I/O before it reaches the actual disk:

Cache ModeBehaviourDefault OnWhen to Use
None I/O goes directly to disk. No host cache involved. Data disks (Ultra, Premium SSD v2) Write-heavy workloads; databases where application-level write-ahead logging already handles durability
ReadOnly Reads are served from host cache (RAM). Writes go directly to disk. Cache is populated on read. Read-heavy data disks: OS images, reference data, read-only databases
ReadWrite Both reads and writes are buffered in host cache before being committed to disk. OS disk Only the OS disk. Never use on database data disks.
ReadWrite cache on database data disks = data loss risk If a VM is deallocated, rebooted, or crashes while ReadWrite cache has pending writes that have not been flushed to the managed disk, those writes are permanently lost. This causes database corruption in transactional workloads (SQL Server, MySQL, PostgreSQL). Always use None or ReadOnly on data disks running databases. This is a critical operations mistake that appears regularly on the exam and in real-world incidents.

Availability: Four Levels of Protection

Azure's availability model is layered. The level of protection you need — and the SLA you can claim — depends on which option you use. These concepts are tested heavily on AZ-104 because the exam loves questions that distinguish between the options and their specific SLA percentages.

Fault Domains and Update Domains

These are the building blocks of Availability Sets:

  • Fault Domain (FD): A physical rack in a datacenter that shares a power source and network switch. VMs in different fault domains will not be simultaneously affected by a rack power failure or network switch failure. Availability sets use 2–3 fault domains.
  • Update Domain (UD): A logical grouping of VMs that Azure reboots together during planned maintenance. Azure guarantees it will only reboot one update domain at a time. Default: 5 UDs per availability set. Azure waits 30 minutes between UDs during maintenance.

Availability Comparison

OptionProtects AgainstDoes NOT Protect AgainstSLAKey Constraint
No availability config Nothing beyond Azure's internal host maintenance Host failure, rack failure, datacenter failure 99.9% (single VM with Premium SSD)
Availability Set Rack power/network failure (FDs); planned maintenance reboots (UDs) Datacenter failure, regional failure 99.95% All VMs in same datacenter. Must be set at VM creation.
Availability Zone Datacenter failure (zone failure); rack and power failures within zone Regional failure (both regions of a region pair) 99.99% VMs in different physical datacenters in same region. Must be set at VM creation.
Azure Site Recovery (cross-region) Regional failure Based on RPO/RTO targets (not a VM SLA) Separate service; DR, not HA
Availability Zones — the 99.99% answer Whenever an exam question asks how to achieve 99.99% VM SLA, the answer is Availability Zones. Deploying two or more VMs in different zones within the same region gives you 99.99% uptime SLA from Microsoft. The zones are physically separate datacenters with independent power, cooling, and networking — a failure in one zone does not affect the others.

Proximity Placement Groups

Proximity Placement Groups (PPGs) instruct Azure to co-locate VMs as physically close as possible — in the same datacenter, on the same compute cluster. This minimises network latency between VMs, which is critical for tightly coupled workloads like HPC clusters or multi-tier apps with microsecond latency requirements.

The trade-off: PPGs reduce fault tolerance. If the underlying host cluster or datacenter experiences a failure, all VMs in the PPG may be affected simultaneously. PPGs and full availability zone isolation are inherently in tension — you must choose based on your workload's latency vs. resilience requirements.

Azure Spot VMs

Spot VMs allow you to use Azure's unused compute capacity at up to 90% discount compared to pay-as-you-go pricing. The catch: Azure can evict a spot VM at any time — with only 30 seconds notice — when Azure needs the capacity back for standard-priority workloads.

AspectDetails
Eviction policy Stop/Deallocate (VM is stopped and deallocated but disk preserved) or Delete (VM and disk deleted on eviction)
Eviction notice 30-second notice via Azure Metadata Service or Azure Scheduled Events
Max price Optionally set a maximum price you're willing to pay per hour; eviction occurs if spot price exceeds max
Suitable workloads Batch processing, data analytics, CI/CD agents, development environments, stateless web tiers with graceful shutdown
Unsuitable workloads Databases, stateful apps, production user-facing services, anything requiring guaranteed availability
Spot VMs and VMSS Spot VMs are commonly combined with VM Scale Sets using a mixed instance policy (some standard instances + some spot instances). This lets you run the majority of capacity on cheap spot while maintaining a baseline of standard instances that won't be evicted. This pattern is common in large-scale batch and ML workloads.

VM Extensions

VM extensions are small agent packages that run inside the VM to provide post-deployment automation and integration with Azure services. They run under the Azure VM Guest Agent, which must be running on the VM.

ExtensionPurposeKey Points
Custom Script Extension (CSE) Runs a shell script (Windows: PowerShell/CMD; Linux: bash) on the VM at deployment or on-demand One-shot execution — not idempotent by design. Re-running requires updating the script version. Download script from Azure Storage, GitHub, or embed in extension JSON.
Azure Monitor Agent (AMA) Collects performance metrics, event logs, syslog from the VM and sends to Log Analytics Workspace Replaces legacy Log Analytics Agent (MMA/OMS) and Azure Diagnostics extension. Required for VM Insights, Change Tracking, Update Manager in 2026. Uses Data Collection Rules (DCRs) for fine-grained data collection configuration.
Azure Disk Encryption (ADE) Encrypts OS and data disks at the volume level Windows: BitLocker; Linux: dm-crypt. Encryption keys stored in Azure Key Vault. Requires Key Vault to be in same subscription. Distinct from SSE (Server-Side Encryption) which is Azure-managed and always on.
PowerShell DSC PowerShell Desired State Configuration for declarative Windows configuration management Good for enforcing OS configuration state (installed roles, services, registry keys). Idempotent. Can integrate with Azure Automation State Configuration.
VM Access Extension Reset admin passwords, SSH keys, or network configuration on a locked-out VM Emergency use. Allows recovery without console access when SSH/RDP is broken.
AMA replaces MMA — retirement timeline The legacy Log Analytics Agent (MMA, also called OMS agent) was deprecated and retired in 2024. All VMs should now use the Azure Monitor Agent (AMA) with Data Collection Rules. If you still see exam or scenario content referencing MMA/OMS, treat AMA as the correct modern answer. Key difference: AMA uses DCRs for configuration rather than Log Analytics workspace settings, enabling more granular and cost-efficient data collection.

VM Snapshots vs. Azure Backup

There are two ways to create point-in-time recovery points for a VM's disks. Understanding when to use each is important for both the exam and production operations.

MethodMechanismApplication Consistent?Use CaseCost
Managed Disk Snapshot Full or incremental copy of a single managed disk, stored in Azure Crash-consistent only (unless VM is quiesced) Pre-change safety copy before risky disk operations; ad-hoc disk restore Storage cost for snapshot data (incremental after first)
Azure Backup for VMs VSS-coordinated (Windows) or fsfreeze (Linux) snapshot of all VM disks via Recovery Services Vault Yes — application-consistent for most workloads Scheduled, policy-driven backup with long-term retention; BCDR Vault storage + backup instance fee
Disk snapshots are not VM backups A managed disk snapshot is a copy of a single disk at a point in time. A VM typically has an OS disk and one or more data disks. If you snapshot each disk separately (not simultaneously), there is no consistency guarantee across them — a database transaction could be split across the OS disk and data disk snapshot timestamps. Use Azure Backup for VM-level consistent recovery. Use snapshots for quick, single-disk, pre-change safety nets.

Azure Hybrid Benefit

Azure Hybrid Benefit (AHB) allows you to apply existing on-premises Windows Server licenses with Software Assurance to Azure VMs — paying Linux pricing for Windows VMs. The savings can reach up to 49% on Windows VM compute costs.

AHB can also be applied to SQL Server licences (avoiding SQL license charges on Azure VMs) and to Azure Stack HCI licensing. For Windows VMs, AHB is toggled at VM creation time or applied to existing VMs without downtime — it is purely a billing flag.

Resizing VMs

VM resize behaviour depends on whether the target size is available on the same physical host cluster as the current VM:

  • Same family, nearby sizes: Azure can often resize without deallocating the VM — brief reboot but no full deallocation. Example: D4s_v5 → D8s_v5.
  • Cross-family resize: Requires VM deallocation (the VM is stopped and its compute allocation released). The VM is reassigned to a different host cluster that supports the target family. This causes downtime. Example: D4s_v5 → E8s_v5.
Resize and availability sets If a VM is in an availability set, all VMs in the same availability set must support the target size — because they share the same physical host cluster. If you try to resize to a size not available on that cluster, the resize will fail. You may need to stop all VMs in the availability set first to allow Azure to reallocate them to a different cluster that supports the target size.

Check Your Understanding

Click any option to see immediate feedback. Answers represent correct behaviour in a real Azure environment.

1. You are deploying a two-VM application tier and need to achieve a 99.99% SLA for the tier's uptime. What deployment configuration achieves this?

Deploying VMs in different Availability Zones gives you the 99.99% multi-VM SLA. Availability Zones are physically separate datacenters with independent power, cooling, and networking — a zone failure only affects VMs in that zone. An Availability Set provides 99.95% SLA (same datacenter, different racks), which doesn't protect against datacenter failures. Azure Site Recovery is a DR tool (not an HA solution) and has no SLA for VM uptime continuity.

2. You need a 2 TiB data disk that supports 50,000 IOPS and 600 MB/s throughput, configurable independently of the disk size. Which Azure managed disk type meets this requirement?

Premium SSD v2 is the correct answer. It allows you to independently set disk size, IOPS, and throughput — you can have a 2 TiB disk with exactly the IOPS and throughput your workload needs, without over-provisioning storage. Premium SSD v1 ties IOPS and throughput to the P-series size tier (P50 = 2 TiB = 7,500 IOPS, which is less than the required 50,000). Ultra Disk also supports independent configuration but requires an Availability Zone deployment and is more expensive; it cannot be used as an OS disk.

3. A database team configures ReadWrite disk caching on the data disks of their SQL Server VM for maximum write performance. What risk have they introduced?

ReadWrite cache buffers writes in the host server's RAM before committing them to the managed disk. If the VM (or the host) crashes before the cached writes are flushed, the data in the host cache is permanently lost — it never reached the durable storage. For SQL Server data and log disks, this means transaction log records or data pages could be missing after a crash recovery, leaving the database in a corrupted state. Always use None for database data disks. ReadOnly cache is safe for data disks that are read-heavy (e.g. OS disks, reference data).

4. You have two VMs in an Availability Set with 2 Fault Domains. The rack hosting Fault Domain 0 loses power. What is the expected outcome?

Correct. The availability set ensures that the two VMs are on different physical racks (fault domains), so a single rack power failure only takes down one VM. The surviving VM (on FD 1) continues running. However, both VMs are in the same datacenter — so a full datacenter failure (fire, flooding, major power failure) would take down both. For datacenter-level protection, you need Availability Zones.

5. A developer wants to use Azure Spot VMs for a production API that handles user-facing requests. You need to explain why this is inappropriate. What is the primary technical risk?

The critical issue with Spot VMs is the 30-second eviction notice. Azure can reclaim spot capacity at any moment when demand from standard-priority customers increases. A user-facing production API would experience immediate downtime with no meaningful recovery window. 30 seconds is only enough time to signal an eviction handler to do a very fast graceful shutdown — sufficient for a batch job to checkpoint, but not for a stateful API to drain connections and hand off work. Spot VMs are excellent for batch, CI/CD, ML training, and other interruptible workloads.

6. An architect asks which VM monitoring agent you should deploy on new Azure VMs in 2026 for metric collection, log forwarding to a Log Analytics workspace, and VM Insights. What is the correct answer?

The Azure Monitor Agent (AMA) is the correct and current answer. The legacy Log Analytics Agent (MMA/OMS) was retired in 2024 — do not install it on new VMs. AMA collects metrics, Windows Event Logs, Performance Counters, and Linux Syslog via Data Collection Rules (DCRs), which give you fine-grained control over what data is collected and where it is sent. It is required for VM Insights (the VM monitoring feature in Azure Monitor), Change Tracking, and Azure Update Manager in 2026.
Primary source for this lesson Virtual machines in Azure — Overview (Microsoft Learn)

Follow the linked articles on managed disk types, availability options, and VM extensions. The managed disks overview and the availability options comparison page are essential reading before your exam.

Questions for your teacher (the AI agent)
This lesson covered VM fundamentals at depth. Explore further with any of these:
  • Walk me through creating a generalised Windows Server image using Sysprep and storing it in an Azure Compute Gallery with regional replication.
  • How do I configure Azure Disk Encryption (ADE) on an existing VM — what Key Vault settings are required?
  • Explain the difference between Azure Disk Encryption (ADE), Server-Side Encryption (SSE), and host-based encryption — when would you use each?
  • How do Proximity Placement Groups interact with Availability Zones — can you use both simultaneously?
Coming up: Lesson 10 — VM Scale Sets, Azure Bastion & JIT Access Lesson 10 builds on VM fundamentals to cover fleet management (VMSS), and the two most important secure access patterns for VMs in enterprise environments: Azure Bastion (no public IP, browser-based RDP/SSH) and Just-In-Time access (time-limited NSG rules). Both are heavily tested on AZ-104.