az vm unmanaged-disk

Manage the unmanaged data disks attached to a VM.

Just like any other computer, virtual machines in Azure 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. Operating System Disk Every virtual machine has one attached operating system disk. It's registered as a SATA drive and is labeled /dev/sda by default. This disk has a maximum capacity of 1023 gigabytes (GB). Temporary disk The temporary disk is automatically created for you. On Linux virtual machines, the disk is typically /dev/sdb and is formatted and mounted to /mnt/resource by the Azure Linux Agent. The size of the temporary disk varies, based on the size of the virtual machine. Data disk A data disk is a VHD that's attached to a virtual machine to store application data, or other data you need to keep. Data disks are registered as SCSI drives and are labeled by the creator. Each data disk has a maximum capacity of 1023 GB. The size of the virtual machine determines how many data disks can be attached and the type of storage that can be used to host the disks.

Commands

az vm unmanaged-disk attach Attach an unmanaged persistent disk to a VM.
az vm unmanaged-disk detach Detatch an unmanaged disk from a VM.
az vm unmanaged-disk list List unamanaged disks of a VM.

az vm unmanaged-disk attach

Attach an unmanaged persistent disk to a VM.

az vm unmanaged-disk attach --resource-group
--vm-name
[--caching {None, ReadOnly, ReadWrite}]
[--lun]
[--name]
[--new]
[--size-gb]
[--vhd-uri]

Examples

Attach a new default sized (1023 GB) unmanaged data disk to a VM.

az vm unmanaged-disk attach -g MyResourceGroup --vm-name MyVm

Attach an existing data disk to a VM as unmanaged.

az vm unmanaged-disk attach -g MyResourceGroup --vm-name MyVm     --vhd-uri https://mystorage.blob.core.windows.net/vhds/d1.vhd

Required Parameters

--resource-group -g
Name of resource group. You can configure the default group using `az configure --defaults group=<name>`.
--vm-name
The name of the Virtual Machine. You can configure the default using `az configure --defaults vm=<name>`.

Optional Parameters

--caching
Disk caching policy.
accepted values: None, ReadOnly, ReadWrite
--lun
0-based logical unit number (LUN). Max value depends on the Virtual Machine size.
--name -n
The data disk name(optional when create a new disk).
--new
Create a new disk.
--size-gb
default value: 1023
--vhd-uri
Virtual hard disk's uri. For example:https://mystorage.blob.core.windows.net/vhds/d1.vhd.

az vm unmanaged-disk detach

Detatch an unmanaged disk from a VM.

az vm unmanaged-disk detach --name
--resource-group
--vm-name

Examples

Detach a data disk from a VM.

az vm unmanaged-disk detach -g MyResourceGroup --vm-name MyVm -n disk_name

Required Parameters

--name -n
The data disk name.
--resource-group -g
Name of resource group. You can configure the default group using `az configure --defaults group=<name>`.
--vm-name
The name of the Virtual Machine. You can configure the default using `az configure --defaults vm=<name>`.

az vm unmanaged-disk list

List unamanaged disks of a VM.

az vm unmanaged-disk list --name
--resource-group

Examples

List the unmanaged disks attached to a VM.

az vm unmanaged-disk list -g MyResourceGroup --vm-name MyVm

List unamanaged disks with IDs containing the string "data_disk".

az vm unmanaged-disk list --ids     $(az resource list --query "[?contains(name, 'data_disk')].id" -o tsv)

Required Parameters

--name -n
The name of the Virtual Machine. You can configure the default using `az configure --defaults vm=<name>`.
--resource-group -g
Name of resource group. You can configure the default group using `az configure --defaults group=<name>`.