从 Azure 下载 Windows VHDDownload a Windows VHD from Azure

本文介绍如何使用 Azure 门户从 Azure 下载 Windows 虚拟硬盘 (VHD) 文件。In this article, you learn how to download a Windows virtual hard disk (VHD) file from Azure using the Azure portal.

可选:通用化 VMOptional: Generalize the VM

如果要使用 VHD 作为映像来创建其他 VM,则应使用 Sysprep 来通用化操作系统。If you want to use the VHD as an image to create other VMs, you should use Sysprep to generalize the operating system. 否则,必须为要创建的每个 VM 复制磁盘。Otherwise, you will have to make a copy the disk for each VM you want to create.

若要使用 VHD 作为映像创建其他 VM,请通用化该 VM。To use the VHD as an image to create other VMs, generalize the VM.

  1. 登录到 Azure 门户(如果未登录)。If you haven't already done so, sign in to the Azure portal.
  2. 连接到 VMConnect to the VM.
  3. 在 VM 上,以管理员身份打开“命令提示符”窗口。On the VM, open the Command Prompt window as an administrator.
  4. 将目录切换到 %windir%\system32\sysprep,然后运行 sysprep.exe。Change the directory to %windir%\system32\sysprep and run sysprep.exe.
  5. 在“系统准备工具”对话框中,选择“进入系统全新体验(OOBE)”,确保已选中“通用化”。In the System Preparation Tool dialog box, select Enter System Out-of-Box Experience (OOBE), and make sure that Generalize is selected.
  6. 在“关闭选项”中选择“关闭”,然后单击“确定”。In Shutdown Options, select Shutdown, and then click OK.

如果不想通用化当前 VM,仍可首先创建 OS 磁盘的快照、从快照创建新的 VM,然后对副本进行通用化,从而创建通用映像。If you don't want to generalize your current VM, you can still create a generalized image by first making a snapshot of the OS disk, creating a new VM from the snapshot, and then generalizing the copy.

停止 VMStop the VM

如果 VHD 附加到正在运行的 VM,则不能从 Azure 下载。A VHD can’t be downloaded from Azure if it's attached to a running VM. 如果要使 VM 保持运行,可创建快照,然后下载快照If you want to keep the VM running, you can create a snapshot and then download the snapshot.

  1. 在 Azure 门户的“中心”菜单上,单击“虚拟机”。On the Hub menu in the Azure portal, click Virtual Machines.
  2. 从列表中选择 VM。Select the VM from the list.
  3. 在 VM 的边栏选项卡上,单击“停止”。On the blade for the VM, click Stop.

替代方法:创建 VM 磁盘快照Alternative: Snapshot the VM disk

创建要下载的磁盘快照。Take a snapshot of the disk to download.

  1. 门户中选择 VM。Select the VM in the portal.
  2. 在左侧菜单中选择“磁盘”,然后选择要创建快照的磁盘。Select Disks in the left menu and then select the disk you want to snapshot. 系统将显示磁盘的详细信息。The details of the disk will be displayed.
  3. 从页面的顶部菜单选择“创建快照”。Select Create Snapshot from the menu at the top of the page. “创建快照”页将打开。The Create snapshot page will open.
  4. 在“名称”中键入快照的名称。In Name, type a name for the snapshot.
  5. 对于“快照类型”,选择“完全”或“增量” 。For Snapshot type, select Full or Incremental.
  6. 完成操作后,选择“查看 + 创建”。When you are done, select Review + create.

快照将很快创建,然后可用于下载或从中创建另一个 VM。Your snapshot will be created shortly, and may then be used to download or create another VM from.

备注

如果不先停止 VM,快照将不会清理。If you don't stop the VM first, the snapshot will not be clean. 快照的状态就好像在创建快照时 VM 已重启或崩溃一样。The snapshot will be in the same state as if the VM had been power cycled or crashed at the point in time when the snapshot was made. 尽管这通常是安全的,但如果当时正在运行的应用程序会因崩溃受到影响,则可能会导致问题。While usually safe, it could cause problems if the running applications running a the time were not crash resistant.

仅建议具有单个操作系统磁盘的 VM 使用此方法。This method is only recommended for VMs with a single OS disk. 在下载快照之前或为操作系统磁盘和每个数据磁盘创建快照之前,应停止具有一个或多个数据磁盘的 VM。VMs with one or more data disks should be stopped before download or before creating a snapshot for the OS disk and each data disk.

生成下载 URLGenerate download URL

若要下载 VHD 文件,需要生成共享访问签名 (SAS) URL。To download the VHD file, you need to generate a shared access signature (SAS) URL. 生成 URL 时,将为 URL 分配到期时间。When the URL is generated, an expiration time is assigned to the URL.

  1. 在 VM 的页面上,单击左侧菜单中的“磁盘”。On the page for the VM, click Disks in the left menu.
  2. 选择 VM 的操作系统磁盘。Select the operating system disk for the VM.
  3. 在磁盘的页面上,从左侧菜单中选择“磁盘导出”。On the page for the disk, select Disk Export from the left menu.
  4. URL 默认的过期时间为 3600 秒(1 小时)。The default expiration time of the URL is 3600 seconds (one hour). 对于 Windows OS 磁盘或大型数据磁盘,可能需要增加此时间。You may need to increase this for Windows OS disks or large data disks. 通常,36000 秒(10 小时)足够了。36000 seconds (10 hours) is usually sufficient.
  5. 单击“生成 URL”。Click Generate URL.

备注

从默认值增加到期时间,以便提供足够时间来下载 Windows Server 操作系统的大型 VHD 文件。The expiration time is increased from the default to provide enough time to download the large VHD file for a Windows Server operating system. 下载大型 VHD 可能需要几个小时,具体取决于你的连接和 VM 大小。Large VHDs can take up to several hours to download depending on your connection and the size of the VM.

下载 VHDDownload VHD

  1. 在生成的 URL 下,单击“下载 VHD 文件”。Under the URL that was generated, click Download the VHD file.
  2. 可能需要单击浏览器中的“保存”以开始下载。You may need to click Save in your browser to start the download. VHD 文件的默认名称为 abcdThe default name for the VHD file is abcd.

后续步骤Next steps