LinuxCommandLibrary

az-disk

Manage Azure managed disks

TLDR

Create a managed disk

$ az disk create [[-g|--resource-group]] [resource_group] [[-n|--name]] [disk_name] [[-z|--size-gb]][size_in_gb]
copy

List managed disks in a resource group
$ az disk list [[-g|--resource-group]] [resource_group]
copy

Delete a managed disk
$ az disk delete [[-g|--resource-group]] [resource_group] [[-n|--name]] [disk_name]
copy

Grant read or write access to a managed disk (for export)
$ az disk grant-access [[-g|--resource-group]] [resource_group] [[-n|--name]] [disk_name] [[--access|--access-level]] [Read|Write] --duration-in-seconds [seconds]
copy

Update disk size
$ az disk update [[-g|--resource-group]] [resource_group] [[-n|--name]] [disk_name] [[-z|--size-gb]] [new_size_in_gb]
copy

SYNOPSIS

az disk [--resource-group <group>] [--name <name>] [--subscription <sub>] [--output <format>] <create|delete|list|list-skus|show|update|wait> [options]

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: json|jsonc|table|tsv|yaml|yamlc [default: json].

--query
    JMESPath query string. See http://jmespath.org/.

--subscription
    Name or ID of subscription. Set default with az account set -s NAME_OR_ID.

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

--ids
    Space-delimited resource IDs. No other resource ID args if specified.

--name -n, --disk-name
    Name or ID of the disk.

--resource-group -g
    Name of resource group. Set default with az configure --defaults group=<name>.

DESCRIPTION

az disk is a command group in the Azure Command-Line Interface (Azure CLI), designed for creating, managing, and deleting Azure Managed Disks. These disks provide scalable, high-performance block storage for Azure Virtual Machines (VMs), eliminating the need to manage storage accounts directly.

Key capabilities include provisioning disks with various SKUs (e.g., Premium SSD, Standard HDD, Ultra Disks), cloning from snapshots or images, resizing, changing tiers or encryption settings, listing available SKUs and disks in a resource group or subscription, and monitoring status with wait conditions. The attachment subgroup handles VM disk attachments.

Usage requires Azure CLI installation, authentication via az login, and specifying a resource group. Commands support JSON querying with JMESPath and multiple output formats. It's essential for IaC scripts, automation, and VM lifecycle management in Azure cloud environments.

Supports advanced features like host caching, bursting, and cross-region replication, making it integral for production workloads.

CAVEATS

Requires Azure CLI 2.0+, az login authentication, and permissions like Microsoft.Compute/disks/*. Operations billed by provisioned size/type; delete does not affect snapshots/VMs. Not for unmanaged disks.

SUBCOMMANDS

create, delete, list, list-skus, show, update, wait.
Subgroup: az disk attachment (manage VM attachments).

EXAMPLE

az disk create -g myRG -n myDisk --location eastus --size-gb 128 --sku Premium_LRS

HISTORY

Introduced in Azure CLI 2.0 (Dec 2017) with Managed Disks GA. Evolved with features like Ultra Disks (2019), shared disks (2020), confidential disks (2021), and zone-redundant storage (2022+).

SEE ALSO

az snapshot(1), az vm(1), az group(1), lsblk(8)

Copied to clipboard