Overview
Azure Managed Disks provide durable, high‑performance storage for Azure Virtual Machines. This guide explains how to create, attach, detach, resize, and delete disks using the Azure portal, Azure CLI, PowerShell, and REST API.
Disk Types
Type | Use‑case | Performance |
---|---|---|
Standard HDD | Backup, non‑critical workloads | Up to 500 MB/s |
Standard SSD | Web servers, lightly used apps | Up to 750 MB/s |
Premium SSD | Production databases, high‑IO apps | Up to 9,500 MB/s |
Ultra SSD | Data‑intensive, low‑latency workloads | Up to 160,000 MB/s |
Create a Managed Disk
Use the Azure portal, Azure CLI, or PowerShell. Below are CLI and PowerShell examples.
az disk create \ --resource-group MyResourceGroup \ --name myDataDisk \ --size-gb 128 \ --sku Premium_LRS
New-AzDisk -ResourceGroupName "MyResourceGroup" ` -DiskName "myDataDisk" ` -DiskSizeGB 128 ` -SkuName "Premium_LRS"
Attach a Disk to a VM
After the disk is created, attach it to an existing VM.
az vm disk attach \ --resource-group MyResourceGroup \ --vm-name myVM \ --name myDataDisk
Add-AzVMDataDisk -VM $vm ` -Name "myDataDisk" ` -Lun 1 ` -CreateOption Attach ` -Caching ReadWrite Update-AzVM -ResourceGroupName "MyResourceGroup" -VM $vm
Resize a Managed Disk
You can increase the size of a disk without detaching it.
az disk update \ --resource-group MyResourceGroup \ --name myDataDisk \ --size-gb 256
$disk = Get-AzDisk -ResourceGroupName "MyResourceGroup" -DiskName "myDataDisk" $disk.DiskSizeGB = 256 Update-AzDisk -ResourceGroupName "MyResourceGroup" -Disk $disk
Detach and Delete a Disk
Detach before deleting to avoid data loss.
az vm disk detach \ --resource-group MyResourceGroup \ --vm-name myVM \ --name myDataDisk az disk delete \ --resource-group MyResourceGroup \ --name myDataDisk \ --yes
$vm = Get-AzVM -ResourceGroupName "MyResourceGroup" -Name "myVM" Remove-AzVMDataDisk -VM $vm -Name "myDataDisk" Update-AzVM -ResourceGroupName "MyResourceGroup" -VM $vm Remove-AzDisk -ResourceGroupName "MyResourceGroup" -DiskName "myDataDisk"
REST API Reference
For programmatic control, use the Azure Compute REST API.
Troubleshooting
Common issues and resolutions:
- Disk not attaching: Verify the VM’s size supports the selected disk type.
- Resize operation fails: Ensure the disk is not attached to a VM that has the ReadOnly flag.
- Performance lower than expected: Check that the VM SKU and disk SKU are matched appropriately.