az vm disk
Manage the managed data disks attached to a VM.
Azure Virtual Machines use disks as a place to store an operating system, applications, and data. All Azure virtual machines have at least two disks: An operating system disk, and a temporary disk. The operating system disk is created from an image, and both the operating system disk and the image are actually virtual hard disks (VHDs) stored in an Azure storage account. Virtual machines also can have one or more data disks, that are also stored as VHDs.
Azure Managed and Unmanaged Data Disks have a maximum size of 4095 GB (with the exception of larger disks in preview). Azure Unmanaged Disks also have a maximum capacity of 4095 GB.
For more information, see:
- Azure Disks - https://docs.microsoft.com/azure/virtual-machines/managed-disks-overview.
- Larger Managed Disks in Public Preview - https://azure.microsoft.com/blog/introducing-the-public-preview-of-larger-managed-disks-sizes/
- Ultra SSD Managed Disks in Public Preview - https://docs.microsoft.com/azure/virtual-machines/disks-types.
Commands
Name | Description | Type | Status |
---|---|---|---|
az vm disk attach |
Attach a managed persistent disk to a VM. |
Core | GA |
az vm disk detach |
Detach a managed disk from a VM. |
Core | GA |
az vm disk attach
Attach a managed persistent disk to a VM.
This allows for the preservation of data, even if the VM is reprovisioned due to maintenance or resizing.
az vm disk attach --vm-name
[--caching {None, ReadOnly, ReadWrite}]
[--disks]
[--enable-write-accelerator]
[--ids]
[--lun]
[--name]
[--new]
[--resource-group]
[--size-gb]
[--sku {PremiumV2_LRS, Premium_LRS, Premium_ZRS, StandardSSD_LRS, StandardSSD_ZRS, Standard_LRS, UltraSSD_LRS}]
[--subscription]
Examples
Attach a new default sized (1023 GB) managed data disk to a VM.
az vm disk attach -g MyResourceGroup --vm-name MyVm --name disk_name --new
Attach a managed persistent disk to a VM. (autogenerated)
az vm disk attach --name $diskId --new --resource-group MyResourceGroup --size-gb 128 --sku Standard_LRS --vm-name MyVm
Attach multiple managed disks to a VM.
az vm disk attach --vm-name MyVm --resource-group MyResourceGroup --sku Standard_LRS --disks diskId1 diskId2 diskId3
Required Parameters
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Optional Parameters
Disk caching policy.
One or more names or IDs of the managed disk (space-delimited).
Enable write accelerator.
Option '--ids' has been deprecated and will be removed in a future release. Use '--disks' instead.
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.
0-based logical unit number (LUN). Max value depends on the Virtual Machine size.
The name or ID of the managed disk.
Create a new disk.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Size in GB. Max size: 4095 GB (certain preview disks can be larger).
Underlying storage SKU.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
az vm disk detach
Detach a managed disk from a VM.
az vm disk detach --name
--resource-group
--vm-name
[--force-detach]
Examples
Detach a data disk from a VM.
az vm disk detach -g MyResourceGroup --vm-name MyVm --name disk_name
Force detach a data disk from a VM.
az vm disk detach -g MyResourceGroup --vm-name MyVm --name disk_name --force-detach
Required Parameters
The data disk name.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Optional Parameters
Force detach managed data disks from a VM.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
Azure CLI