Create a snapshot

Take a snapshot of an OS or data disk VHD for backup or to troubleshoot VM issues. A snapshot is a full, read-only copy of a VHD.

Use Azure CLI 2.0 to take a snapshot

The following example requires the Azure CLI 2.0 installed and logged into your Azure account. Run az --version to find the version. If you need to install or upgrade, see Install Azure CLI 2.0.

The following steps show how to take a snapshot using the az snapshot create command with the --source-disk parameter. The following example assumes that there is a VM called myVM created with a managed OS disk in the myResourceGroup resource group.

# take the disk id with which to create a snapshot
osDiskId=$(az vm show -g myResourceGroup -n myVM --query "storageProfile.osDisk.managedDisk.id" -o tsv)
az snapshot create -g myResourceGroup --source "$osDiskId" --name osDisk-backup

The output should look something like:

{
  "accountType": "Standard_LRS",
  "creationData": {
    "createOption": "Copy",
    "imageReference": null,
    "sourceResourceId": null,
    "sourceUri": "/subscriptions/<guid>/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/osdisk_6NexYgkFQU",
    "storageAccountId": null
  },
  "diskSizeGb": 30,
  "encryptionSettings": null,
  "id": "/subscriptions/<guid>/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/osDisk-backup",
  "location": "westus",
  "name": "osDisk-backup",
  "osType": "Linux",
  "ownerId": null,
  "provisioningState": "Succeeded",
  "resourceGroup": "myResourceGroup",
  "tags": null,
  "timeCreated": "2017-02-06T21:27:10.172980+00:00",
  "type": "Microsoft.Compute/snapshots"
}

Use Azure portal to take a snapshot

  1. Sign in to the Azure portal.
  2. Starting in the upper-left, click New and search for snapshot.
  3. In the Snapshot blade, click Create.
  4. Enter a Name for the snapshot.
  5. Select an existing Resource group or type the name for a new one.
  6. Select an Azure datacenter Location.
  7. For Source disk, select the Managed Disk to snapshot.
  8. Select the Account type to use to store the snapshot. We recommend Standard_LRS unless you need it stored on a high performing disk.
  9. Click Create.

If you plan to use the snapshot to create a Managed Disk and attach it a VM that needs to be high performing, use the parameter --sku Premium_LRS with the az snapshot create command. This creates the snapshot so that it is stored as a Premium Managed Disk. Premium Managed Disks perform better because they are solid-state drives (SSDs), but cost more than Standard disks (HDDs).

Next steps

Create a virtual machine from a snapshot by creating a managed disk from the snapshot and then attaching the new managed disk as the OS disk. For more information, see the Create a VM from a snapshot script.