az snapshot

Manage point-in-time copies of managed disks, native blobs, or other snapshots.

Commands

az snapshot create Create a snapshot.
az snapshot delete Deletes a snapshot.
az snapshot grant-access Grant read access to a snapshot.
az snapshot list List snapshots.
az snapshot revoke-access Revoke read access to a snapshot.
az snapshot show Gets information about a snapshot.
az snapshot update Update a snapshot.
az snapshot wait Place the CLI in a waiting state until a condition of a snapshot is met.

az snapshot create

Create a snapshot.

az snapshot create --name
--resource-group
[--for-upload {false, true}]
[--hyper-v-generation {V1, V2}]
[--location]
[--no-wait]
[--size-gb]
[--sku {Premium_LRS, Standard_LRS}]
[--source]
[--source-storage-account-id]
[--subscription]
[--tags]

Examples

Create a snapshot by importing from a blob uri.

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

Create an empty snapshot.

az snapshot create -g MyResourceGroup -n MySnapshot --size-gb 10

Create a snapshot by copying an existing disk in the same resource group.

az snapshot create -g MyResourceGroup -n MySnapshot2 --source MyDisk

Create a snapshot from an existing disk in another resource group.

az snapshot create -g MyResourceGroup -n MySnapshot2 --source "/subscriptions/00000/resourceGroups/AnotherResourceGroup/providers/Microsoft.Compute/disks/MyDisk"

Required Parameters

--name -n

The name of the snapshot.

--resource-group -g

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

Optional Parameters

--for-upload

Create the snapshot for uploading blobs later on through storage commands. Run "az snapshot grant-access --access-level Write" to retrieve the snapshot'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.

--size-gb -z

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

--sku
accepted values: Premium_LRS, Standard_LRS
default value: Standard_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.

az snapshot delete

Deletes a snapshot.

az snapshot delete [--ids]
[--name]
[--resource-group]
[--subscription]

Optional Parameters

--ids

One or more resource IDs (space-delimited). If provided, no other 'Resource Id' arguments should be specified.

--name -n

The name of the snapshot.

--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 snapshot grant-access

Grant read access to a snapshot.

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

Examples

Grant read access to a snapshot. (autogenerated)

az snapshot grant-access --duration-in-seconds 3600 --name MySnapshot --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). If provided, no other 'Resource Id' arguments should be specified.

--name -n

The name of the snapshot.

--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 snapshot list

List snapshots.

az snapshot 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 snapshot revoke-access

Revoke read access to a snapshot.

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

Examples

Revoke read access to a snapshot. (autogenerated)

az snapshot revoke-access --name MySnapshot --resource-group MyResourceGroup

Optional Parameters

--ids

One or more resource IDs (space-delimited). If provided, no other 'Resource Id' arguments should be specified.

--name -n

The name of the snapshot.

--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 snapshot show

Gets information about a snapshot.

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

Optional Parameters

--ids

One or more resource IDs (space-delimited). If provided, no other 'Resource Id' arguments should be specified.

--name -n

The name of the snapshot.

--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 snapshot update

Update a snapshot.

az snapshot update [--add]
[--force-string]
[--ids]
[--name]
[--no-wait]
[--remove]
[--resource-group]
[--set]
[--sku {Premium_LRS, Standard_LRS}]
[--subscription]

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

--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). If provided, no other 'Resource Id' arguments should be specified.

--name -n

The name of the snapshot.

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

--sku
accepted values: Premium_LRS, Standard_LRS
--subscription

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

az snapshot wait

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

az snapshot 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 snapshot is met. (autogenerated)

az snapshot wait --exists --name MySnapshot --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). If provided, no other 'Resource Id' arguments should be specified.

--interval

Polling interval in seconds.

default value: 30
--name -n

The name of the snapshot.

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