Virtual Machines
create · resize · managed disks · caching · Trusted Launch · Spot · Hybrid Benefit
By the tools4free.dev team · Last reviewed November 13, 2026
Practice questions for this topic →
Create a VM
- Portal: Virtual machines › Create › Virtual machine. Set name, region, image, size and admin account. The VM name drives the default names of related resources.
- In the quickstart flow, a Windows admin password must be at least 12 characters and meet complexity rules.
- Allow selected ports lets you open RDP (3389) and HTTP (80) during creation. The Management tab has Auto-shutdown (time zone default UTC, optional email notice).
- Deleting the resource group deletes the VM and all related resources.
az vm createdefaults:--priority Regular,--os-disk-caching ReadWrite,--public-ip-sku Standard, vnet 10.0.0.0/16 and subnet 10.0.0.0/24 when it creates a vnet, location from the resource group. For Spot, the eviction policy defaults to Deallocate.--nsg-ruleopens RDP on Windows and SSH on Linux by default.NONEcreates no rule.New-AzVMhas a simple parameter set (the default) that creates the VM and its network resources from-Name,-Credentialand optional-Image,-Size,-Zone,-OpenPorts,-Priority,-EvictionPolicy,-SecurityType. For full control, build a config withNew-AzVMConfig,Set-AzVMOperatingSystem,Set-AzVMSourceImageandAdd-AzVMNetworkInterface, then pass-VM.
Resize a VM
- You can resize a running or a deallocated VM. Resizing a running VM restarts it, even if deallocation is not required.
- Deallocation may be required if the new size is not available on the hardware cluster that hosts the VM. If the size you want is not listed while the VM runs, deallocating may reveal more sizes. Deallocating releases dynamic IP addresses. OS and data disks are not affected.
- Portal: VM › Availability + scale › Size › pick a size › Resize.
- VM in an availability set: if the new size is not on the current cluster, deallocate all VMs in the set.
- Premium Storage needs an "s" size (for example Standard_E4s_v3, not Standard_E4_v3).
- Windows VMs can resize only temp-disk to temp-disk or no-temp-disk to no-temp-disk (Linux can cross). A SCSI-based VM cannot resize to a remote NVMe size.
- Order in the CLI:
az vm list-vm-resize-options, thenaz vm deallocate,az vm resize --size,az vm start. In PowerShell:Get-AzVMSize, set$vm.HardwareProfile.VmSize,Update-AzVM.
Managed disk types
| Type | OS disk? | Max size | Max IOPS | Max throughput | Notes |
|---|---|---|---|---|---|
| Ultra Disk | No | 65,536 GiB | 400,000 | 10,000 MB/s | Created empty as a data disk. No availability sets, no host caching, LRS only (single VM or availability zone). Size from 4 GiB. |
| Premium SSD v2 | No | 65,536 GiB | 80,000 | 2,000 MB/s | No host caching. Baseline 3,000 IOPS and 125 MB/s free. Size from 1 GiB. |
| Premium SSD | Yes | 32,767 GiB | 20,000 | 900 MB/s | P10 128 GiB 500 IOPS; P20 512 GiB 2,300; P30 1,024 GiB 5,000; P50 4,096 GiB 7,500. |
| Standard SSD | Yes | 32,767 GiB | 6,000 | 750 MB/s | |
| Standard HDD | Yes (retiring as OS disk Sep 8, 2028) | 32,767 GiB | 2,000 (3,000 with performance plus) | 500 MB/s | Migrate OS disks to Standard SSD or Premium SSD. |
Disk operations
| Task | What to know |
|---|---|
| Change disk type | Deallocate the VM (it restarts). Managed disks only: convert unmanaged first. Only two changes per day. Standard to Premium needs a Premium-capable VM size. Order: deallocate, resize to a Premium-capable size if needed, az disk update --sku Premium_LRS, start. Valid SKUs: Standard_LRS, StandardSSD_LRS, StandardSSD_ZRS, Premium_ZRS, Premium_LRS. Portal: VM stopped › Disks › disk › Size + performance › Account type. |
| Switch to or from Ultra Disk | Not direct. Migrate with an incremental snapshot (512 logical sector size). |
| Change Ultra or Premium SSD v2 performance | No restart. Up to four performance resizes per 24 hours (creation counts as one for Premium SSD v2). Ultra can take up to an hour to apply. |
| Attach a new data disk | VM › Disks › Create and attach a new disk › Save. Then initialize it in the OS (Disk Management). Disks of 2 TiB or more must use GPT; smaller disks can use MBR or GPT. Only initialize and format new empty disks. |
| Expand a disk | Usually deallocate the VM, except data disks that qualify for expand without downtime. Disks of 4 TiB or less need deallocation and detach to go beyond 4 TiB. OS disk max is 4,095 GiB. MBR limits usable size to 2 TiB. Shrinking is not supported. |
| After expanding | Extend the volume in the OS (DiskPart extend or Disk Management). Expanding the disk and extending the volume are separate steps. Striped volumes cannot be expanded. |
- Host caching defaults: ReadWrite for OS disks, ReadOnly for data disks. Caching is not supported on disks of 4 TiB or more. None is supported only on data disks: None set on an OS disk is overridden to ReadOnly.
- Use ReadOnly for read-heavy data disks (for example SQL data files) and None for log files. Use ReadWrite only if the application writes cached data safely.
- Ultra Disk and Premium SSD v2 do not support host caching.
- The number of data disks you can attach depends on the VM size.
Trusted Launch, Spot and Hybrid Benefit
| Feature | Facts |
|---|---|
| Trusted Launch | The default for newly created Gen2 VMs and scale sets (portal, CLI and PowerShell). Gen2 only. Uses Secure Boot, vTPM and optional boot integrity monitoring through Defender for Cloud. No extra VM price. Can be enabled on existing Gen2 VMs; Gen1 VMs can be upgraded to Gen2 with Trusted Launch. Not supported: Managed Image and Linux VM hibernation. |
| Spot VM | Uses unused capacity at a discount, with no SLA. Azure can evict with 30 seconds notice (best effort, through Scheduled Events). Eviction policy: Deallocate (default) or Delete. A deallocated Spot VM still counts against quota and incurs disk storage charges. Delete removes the VM and its disks. B-series and promo sizes are not supported. Spot can only be set at creation. |
| Spot max price | -1 avoids price-based eviction (you never pay above the standard price). A max price below the current price means the VM is not deployed. To change max price, deallocate first. A VM evicted for price is not restarted automatically. |
| Azure Hybrid Benefit (Windows Server) | Needs on-premises Windows Server core licenses with active Software Assurance or qualifying subscription licenses. Minimum 8 core licenses per VM. License type Windows_Server. Converting an existing VM changes only a metadata licensing flag and does not restart the VM. |
CLI and PowerShell
| Task | Azure CLI | PowerShell |
|---|---|---|
| List resize options | az vm list-vm-resize-options -g <rg> -n <vm> | Get-AzVMSize -ResourceGroupName <rg> -VMName <vm> |
| Resize | az vm resize -g <rg> -n <vm> --size Standard_DS3_v2 | $vm.HardwareProfile.VmSize='…'; Update-AzVM -VM $vm -ResourceGroupName <rg> |
| Deallocate / start | az vm deallocate / az vm start | Stop-AzVM / Start-AzVM |
| Change disk type | az disk update --sku Premium_LRS -n <disk> -g <rg> | $disk.Sku=[…DiskSku]::new('Premium_LRS'); $disk | Update-AzDisk |
| Expand a disk | $disk.DiskSizeGB=1023; Update-AzDisk -ResourceGroupName <rg> -Disk $disk -DiskName $disk.Name | |
| Set host caching to None on a LUN | az vm update -g <rg> -n <vm> --disk-caching 0=None | |
| Create a VM (simple) | az vm create -n MyVm -g MyRG --image Ubuntu2204 --size Standard_D2s_v5 --generate-ssh-keys | New-AzVM -ResourceGroupName MyRG -Name MyVm -Credential (Get-Credential) -Image <img> -Size <size> -Zone 1 |
| Create a Spot VM | az vm create … --priority Spot --eviction-policy Deallocate --max-price -1 | New-AzVM … -Priority Spot -EvictionPolicy Deallocate |
| Enable Hybrid Benefit | az vm update -g MyRG -n MyVm --set licenseType=Windows_Server | $vm.LicenseType="Windows_Server"; Update-AzVM -ResourceGroupName MyRG -VM $vm (None reverts) |
| Trusted Launch | az vm create … --security-type TrustedLaunch | New-AzVM … -SecurityType TrustedLaunch |
Exam Tips
Tick each tip once you can answer it without looking.
“Resize a running VM to a bigger size” → The VM restarts, and may need to be deallocated if the size is not on its cluster. Trap: assuming no downtime.
“The size you want is not listed for a running VM” → Deallocate the VM, then look again. Trap: recreating the VM.
“Resize a VM in an availability set when the size is not on the cluster” → Deallocate all VMs in the availability set. Trap: resizing only the one VM.
“Premium Storage workload on a Standard_E4_v3” → Use an “s” size such as Standard_E4s_v3. Trap: E4_v3 has no Premium Storage support.
“Convert a Standard SSD data disk to Premium SSD” → Deallocate the VM, use a Premium-capable size, update the disk SKU. Trap: detaching the disk is not part of the documented steps.
“Change an existing disk to Ultra Disk” → Not directly: use an incremental snapshot and create a new disk. Trap: az disk update --sku UltraSSD_LRS.
“Ultra Disk in an availability set” → Not supported (single VM or availability zone only).
“Shrink a managed disk” → Not supported: create a new smaller disk and copy the data.
“Disk expanded but the volume is the same size” → Extend the volume in the OS (DiskPart or Disk Management). Trap: restarting alone.
“Initialize a data disk of more than 2 TiB” → GPT. Trap: MBR limits usable size to 2 TiB.
“Raise Ultra Disk IOPS without downtime” → Change the performance at runtime (up to four changes per 24 hours). Trap: detaching the disk.
“A new Gen2 VM from the portal: which security feature is on by default” → Trusted Launch (Secure Boot and vTPM). Trap: Confidential VM or Azure Disk Encryption.
“Interruptible batch workload at the lowest cost” → Spot VM (eviction policy Deallocate, or Delete to drop disks). Trap: expecting an SLA or high availability guarantees.
“Spot VM must not be evicted because of price” → Max price -1. Trap: a max price below the current price: the VM is not deployed.
“Change the max price of a Spot VM” → Deallocate first, then update. Trap: changing it while the VM runs.
“Turn an existing standard VM into a Spot VM” → Not possible: Spot is set at creation. Trap: a portal toggle.
“Use existing Windows Server licenses with Software Assurance on an existing VM” → Set licenseType to Windows_Server: no restart. Trap: redeploying the VM.
“Default host caching for a new data disk” → ReadOnly (OS disk: ReadWrite). Trap: None or ReadWrite for data disks.
“Enable host caching on an 8 TiB data disk” → Not supported on disks of 4 TiB or more.
“az vm create on a Windows image with no --nsg-rule” → An RDP rule is created; --nsg-rule NONE creates none.
Sources
- Resize a virtual machine
- Select a disk type for Azure IaaS VMs
- Convert managed disks between types
- Attach a managed data disk (portal)
- Expand virtual hard disks
- Quickstart: create a Windows VM in the portal
- Trusted Launch
- Azure Spot VMs
- Azure Hybrid Benefit for Windows VMs
- Premium storage performance (host caching)
- az vm create
- New-AzVM
Checked against Microsoft Learn on November 13, 2026.