创建快照Create a snapshot

创建 OS 或数据磁盘的快照作为备份,或用于解决 VM 问题。Take a snapshot of an OS or data disk for backup or to troubleshoot VM issues. 快照是 VHD 的完整只读副本。A snapshot is a full, read-only copy of a VHD.

使用 Azure CLIUse Azure CLI

以下示例需要已安装 Azure CLI。The following example requires that you have the Azure CLI installed.

以下步骤说明如何使用带有 --source-disk 参数的 az snapshot create 命令创建快照。The following steps show how to take a snapshot using the az snapshot create command with the --source-disk parameter. 以下示例假设 myResourceGroup 资源组中存在名为 myVM 的 VM。The following example assumes that there is a VM called myVM in the myResourceGroup resource group.

使用 az vm show 获取磁盘 ID。Get the disk ID using az vm show.

osDiskId=$(az vm show \
   -g myResourceGroup \
   -n myVM \
   --query "storageProfile.osDisk.managedDisk.id" \
   -o tsv)

使用 az snapshot create 创建名为 osDisk-backup 的快照。Take a snapshot named osDisk-backup using az snapshot create.

az snapshot create \
    -g myResourceGroup \
    --source "$osDiskId" \
    --name osDisk-backup

可以使用 az snapshot list 查看快照列表。You can see a list of the snapshots using az snapshot list.

az snapshot list \
   -g myResourceGroup \
   -o table

使用 Azure 门户Use Azure portal

  1. 登录到 Azure 门户Sign in to the Azure portal.
  2. 首先在左上角单击“创建资源”并搜索“快照”。Starting in the upper-left, click Create a resource and search for snapshot. 从搜索结果中选择“快照”。Select Snapshot from the search results.
  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. 对于源磁盘,选择要获取其快照的托管磁盘。For Source disk, select the managed disk to snapshot.
  7. 选择用于存储快照的“帐户类型”。Select the Account type to use to store the snapshot. 使用 Standard HDD,除非需要将其存储在高性能 SSD 上。Use Standard HDD unless you need it stored on a high performing SSD.
  8. 单击创建Click Create.

后续步骤Next steps

通过从快照创建托管磁盘,然后将新的托管磁盘附加为 OS 磁盘,来从快照创建虚拟机。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. 有关详细信息,请参阅从快照创建 VM 脚本。For more information, see the Create a VM from a snapshot script.