You, the admin: build a web server
- Virtual machines › + Create › Azure virtual machine.
- Basics: resource group, name, region, Availability options (none / set / zone; this is your only chance to pick a set), image (Windows Server 2022 or Ubuntu), size (click "See all sizes"), admin username and password or SSH key, inbound ports (leave none open; use Bastion).
- Disks: OS disk type (Premium SSD for production), add data disks.
- Networking: VNet and subnet, public IP (choose None for internal servers), NIC NSG.
- Management: boot diagnostics on, auto-shutdown for dev VMs, enable Azure Backup if you have a vault.
- Review + create. Two to three minutes later: Connect › Bastion.
Script: az vm create -g RG1 -n web1 --image Ubuntu2204 --size Standard_D2s_v5 --vnet-name VNet1 --subnet Web --public-ip-address "" --admin-username azureuser --generate-ssh-keys
How a VM comes to exist
- BasicsName, region, availability option (set / zone, decided now), image, size, admin credentials.
- DisksOS disk type; add data disks.
- NetworkingVNet, subnet, public IP (None for internal servers), NIC NSG.
- Management and createBoot diagnostics, backup, auto-shutdown; Review + create; connect via Bastion.
Sizes
| Letter | Built for |
|---|---|
| B | Cheap and bursty (saves CPU credits when idle) |
| D | General purpose, the default choice |
| E | Lots of memory |
| F | Fast CPU |
| L | Fast local storage |
| M | Enormous memory (SAP HANA) |
| N | GPU |
D4s_v5: D family, 4 vCPUs, s = can use Premium SSD, v5 = hardware generation. To resize: VM › Size, pick, Resize. The VM reboots. If the new size is greyed out or the resize fails with "not available", Stop (deallocate) the VM first; Azure may then place it on hardware that has that size. A deallocated VM costs nothing for compute, but its disks still bill.
Disks
| Type | Use | Rules |
|---|---|---|
| Standard HDD | Backups, dev | No SLA for a single VM |
| Standard SSD | Light web servers | — |
| Premium SSD | Production | VM size must have the "s"; gives the 99.9% single-VM SLA |
| Premium SSD v2 | Dial IOPS and throughput separately | Data disk only |
| Ultra Disk | Highest performance | Data disk only, only in availability zones |
- Always managed disks (Azure handles the storage account). OS disk up to 4 TiB, data disks up to 32 TiB. How many data disks depends on VM size. You can grow a disk; you cannot shrink it.
- Snapshot (Disk › Create snapshot): a copy of one disk at that moment, used to make a new disk. Image: a cleaned, generalised VM (run
sysprep /generalizeon Windows,waagent -deprovision+useron Linux, then VM › Capture) stored in an Azure Compute Gallery so you can stamp out identical VMs. - Encryption: every managed disk is already encrypted at rest. Two extras: Azure Disk Encryption runs BitLocker or dm-crypt inside the guest with a key in Key Vault; Encryption at host encrypts on the physical server so even the temp disk and cache are covered. For encryption at host you first register the feature on the subscription (
az feature register --namespace Microsoft.Compute --name EncryptionAtHost), the VM must be deallocated, and it cannot be combined with Azure Disk Encryption on the same VM.
Moving a VM
| To | How |
|---|---|
| Another resource group or subscription | VM › Move. Select the VM, its disks, NIC, public IP together; validation lists anything that cannot go. |
| Another region | It cannot be relocated. Copy it with Azure Resource Mover or Site Recovery, then delete the original. |
| Another availability set or zone | Not possible in place; recreate from the disks. |
Also on the exam: Custom Script Extension and cloud-init run a script after build; Run Command executes a script from the portal without logging in; boot diagnostics show a screenshot and serial log when a VM will not start; the VM agent must be present for any extension.