az vm unmanaged-disk

Manage the unmanaged 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:

Commands

Name Description Type Status
az vm unmanaged-disk attach

Attach an unmanaged persistent disk to a VM.

Core GA
az vm unmanaged-disk detach

Detach an unmanaged disk from a VM.

Core GA
az vm unmanaged-disk list

List unmanaged disks of a VM.

Core GA

az vm unmanaged-disk attach

Attach an unmanaged 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 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 --new

Attach an existing data disk to a VM as unmanaged.

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

Attach an unmanaged persistent disk to a VM. (autogenerated)

az vm unmanaged-disk attach --name MyDataDisk --new --resource-group MyResourceGroup --size-gb 50 --vm-name MyVm

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.

--new

Create a new disk.

default value: False
--size-gb -z

Size in GB. Max size: 4095 GB (certain preview disks can be larger).

default value: 1023
--vhd-uri

Virtual hard disk URI. For example: https://mystorage.blob.core.windows.net/vhds/d1.vhd.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm unmanaged-disk detach

Detach 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>.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm unmanaged-disk list

List unmanaged 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 unmanaged disks with names containing the string "data_disk".

az vm unmanaged-disk list -g MyResourceGroup --vm-name MyVm \
    --query "[?contains(name, 'data_disk')]" --output table

Required Parameters

--name --vm-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>.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.