az disk

Manage Azure Managed Disks.

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

az disk create Create a managed disk.
az disk delete Delete a managed disk.
az disk grant-access Grant a resource access to a managed disk.
az disk list List managed disks.
az disk revoke-access Revoke a resource's read access to a managed disk.
az disk show Gets information about a disk.
az disk update Update a managed disk.
az disk wait Place the CLI in a waiting state until a condition of a managed disk is met.

az disk create

Create a managed disk.

az disk create --name
--resource-group
[--disk-iops-read-write]
[--disk-mbps-read-write]
[--for-upload {false, true}]
[--hyper-v-generation {V1, V2}]
[--location]
[--no-wait]
[--os-type {Linux, Windows}]
[--size-gb]
[--sku {Premium_LRS, StandardSSD_LRS, Standard_LRS, UltraSSD_LRS}]
[--source]
[--source-storage-account-id]
[--subscription]
[--tags]
[--upload-size-bytes]
[--zone {1, 2, 3}]

Examples

Create a managed disk by importing from a blob uri.

az disk create -g MyResourceGroup -n MyDisk --source https://vhd1234.blob.core.windows.net/vhds/osdisk1234.vhd

Create an empty managed disk.

az disk create -g MyResourceGroup -n MyDisk --size-gb 10

Create a managed disk by copying an existing disk or snapshot.

az disk create -g MyResourceGroup -n MyDisk2 --source MyDisk

Create a disk in an availability zone in the region of "East US 2"

az disk create -n MyDisk -g MyResourceGroup --size-gb 10 --location eastus2 --zone 1

Required Parameters

--name -n

The name of the managed disk.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

--disk-iops-read-write

The number of IOPS allowed for this disk. Only settable for UltraSSD disks. One operation can transfer between 4k and 256k bytes.

--disk-mbps-read-write

The bandwidth allowed for this disk. Only settable for UltraSSD disks. MBps means millions of bytes per second with ISO notation of powers of 10.

--for-upload

Create the disk for uploading blobs later on through storage commands. Run "az disk grant-access --access-level Write" to retrieve the disk's SAS token.

accepted values: false, true
--hyper-v-generation

The hypervisor generation of the Virtual Machine. Applicable to OS disks only.

accepted values: V1, V2
default value: V1
--location -l

Location. Values from: az account list-locations. You can configure the default location using az configure --defaults location=<location>.

--no-wait

Do not wait for the long-running operation to finish.

--os-type

The Operating System type of the Disk.

accepted values: Linux, Windows
--size-gb -z

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

--sku

Underlying storage SKU.

accepted values: Premium_LRS, StandardSSD_LRS, Standard_LRS, UltraSSD_LRS
default value: Premium_LRS
--source

Source to create the disk/snapshot from, including unmanaged blob uri, managed disk id or name, or snapshot id or name.

--source-storage-account-id

Used when source blob is in a different subscription.

--subscription

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

--tags

Space-separated tags in 'key[=value]' format. Use "" to clear existing tags.

--upload-size-bytes

The size (in bytes) of the contents of the upload including the VHD footer. Min value: 20972032. Max value: 35183298347520.

--zone

Availability zone into which to provision the resource.

accepted values: 1, 2, 3

az disk delete

Delete a managed disk.

az disk delete [--ids]
[--name]
[--no-wait]
[--resource-group]
[--subscription]
[--yes]

Examples

Delete a managed disk. (autogenerated)

az disk delete --name MyManagedDisk --resource-group MyResourceGroup

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.

--name -n

The name of the managed disk.

--no-wait

Do not wait for the long-running operation to finish.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

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

--yes -y

Do not prompt for confirmation.

az disk grant-access

Grant a resource access to a managed disk.

az disk grant-access --duration-in-seconds
[--access-level {Read, Write}]
[--ids]
[--name]
[--resource-group]
[--subscription]

Examples

Grant a resource read access to a managed disk. (autogenerated)

az disk grant-access --duration-in-seconds 3600 --name MyManagedDisk --resource-group MyResourceGroup

Required Parameters

--duration-in-seconds

Time duration in seconds until the SAS access expires.

Optional Parameters

--access-level

Access level.

accepted values: Read, Write
default value: Read
--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.

--name -n

The name of the managed disk.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

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

az disk list

List managed disks.

az disk list [--resource-group]
[--subscription]

Optional Parameters

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

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

az disk revoke-access

Revoke a resource's read access to a managed disk.

az disk revoke-access [--ids]
[--name]
[--resource-group]
[--subscription]

Examples

Revoke a resource's read access to a managed disk. (autogenerated)

az disk revoke-access --ids $id

Revoke a resource's read access to a managed disk. (autogenerated)

az disk revoke-access --name MyManagedDisk --resource-group MyResourceGroup

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.

--name -n

The name of the managed disk.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

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

az disk show

Gets information about a disk.

az disk show [--ids]
[--name]
[--resource-group]
[--subscription]

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.

--name -n

The name of the managed disk.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

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

az disk update

Update a managed disk.

az disk update [--add]
[--disk-iops-read-write]
[--disk-mbps-read-write]
[--force-string]
[--ids]
[--name]
[--no-wait]
[--remove]
[--resource-group]
[--set]
[--size-gb]
[--sku {Premium_LRS, StandardSSD_LRS, Standard_LRS, UltraSSD_LRS}]
[--subscription]

Examples

Update a managed disk. (autogenerated)

az disk update --name MyManagedDisk --resource-group MyResourceGroup --size-gb 20

Optional Parameters

--add

Add an object to a list of objects by specifying a path and key value pairs. Example: --add property.listProperty <key=value, string or JSON string>.

--disk-iops-read-write

The number of IOPS allowed for this disk. Only settable for UltraSSD disks. One operation can transfer between 4k and 256k bytes.

--disk-mbps-read-write

The bandwidth allowed for this disk. Only settable for UltraSSD disks. MBps means millions of bytes per second with ISO notation of powers of 10.

--force-string

When using 'set' or 'add', preserve string literals instead of attempting to convert to JSON.

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.

--name -n

The name of the managed disk.

--no-wait

Do not wait for the long-running operation to finish.

--remove

Remove a property or an element from a list. Example: --remove property.list OR --remove propertyToRemove.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--set

Update an object by specifying a property path and value to set. Example: --set property1.property2=.

--size-gb -z

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

--sku

Underlying storage SKU.

accepted values: Premium_LRS, StandardSSD_LRS, Standard_LRS, UltraSSD_LRS
--subscription

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

az disk wait

Place the CLI in a waiting state until a condition of a managed disk is met.

az disk wait [--created]
[--custom]
[--deleted]
[--exists]
[--ids]
[--interval]
[--name]
[--resource-group]
[--subscription]
[--timeout]
[--updated]

Examples

Place the CLI in a waiting state until a condition of a managed disk is met. (autogenerated)

az disk wait --created --name MyManagedDisk --resource-group MyResourceGroup

Optional Parameters

--created

Wait until created with 'provisioningState' at 'Succeeded'.

--custom

Wait until the condition satisfies a custom JMESPath query. E.g. provisioningState!='InProgress', instanceView.statuses[?code=='PowerState/running'].

--deleted

Wait until deleted.

--exists

Wait until the resource exists.

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.

--interval

Polling interval in seconds.

default value: 30
--name -n

The name of the managed disk.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

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

--timeout

Maximum wait in seconds.

default value: 3600
--updated

Wait until updated with provisioningState at 'Succeeded'.