使用 Azure 门户在 VHD 中创建 VMCreate a VM from a VHD by using the Azure portal

有多种方法可在 Azure 中创建虚拟机 (VM):There are several ways to create a virtual machine (VM) in Azure:

  • 如果已经有一个要使用的虚拟硬盘 (VHD),或者需要从要使用的现有 VM 复制 VHD,可以将 VHD 附加到新 VM 作为 OS 磁盘,以此创建新的 VM 。If you already have a virtual hard disk (VHD) to use or you want to copy the VHD from an existing VM to use, you can create a new VM by attaching the VHD to the new VM as an OS disk.

  • 可从已删除的 VM 的 VHD 创建新的 VM。You can create a new VM from the VHD of a VM that has been deleted. 例如,如果 Azure VM 运行不正常,则可以删除该 VM,然后使用其 VHD 创建新的 VM。For example, if you have an Azure VM that isn't working correctly, you can delete the VM and use its VHD to create a new VM. 可以重用同一 VHD,也可以创建 VHD 的副本,方法是:先创建快照,然后根据快照创建新的托管磁盘。You can either reuse the same VHD or create a copy of the VHD by creating a snapshot and then creating a new managed disk from the snapshot. 虽然创建快照需要多个步骤,但它可以保留原始 VHD 并提供回退的依据。Although creating a snapshot takes a few more steps, it preserves the original VHD and provides you with a fallback.

  • 获取经典 VM,并通过 VHD 创建使用资源管理器部署模型和托管磁盘的新 VM。Take a classic VM and use the VHD to create a new VM that uses the Resource Manager deployment model and managed disks. 为了获得最佳结果,在创建快照之前,请在 Azure 门户中停止经典 VM。For the best results, Stop the classic VM in the Azure portal before creating the snapshot.

  • 可以通过上传本地 VHD 并将其附加到新 VM,在本地 VHD 上创建 Azure VM。You can create an Azure VM from an on-premises VHD by uploading the on-premises VHD and attaching it to a new VM. 可使用 PowerShell 或其他工具将 VHD 上传到存储帐户,然后根据 VHD 创建托管磁盘。You use PowerShell or another tool to upload the VHD to a storage account, and then you create a managed disk from the VHD. 有关详细信息,请参阅上传专用 VHDFor more information, see Upload a specialized VHD.

如果想创建多个 VM,请勿使用专用磁盘。Don't use a specialized disk if you want to create multiple VMs. 对于较大的部署,应先创建映像,然后使用该映像创建多个 VMInstead, for larger deployments, create an image and then use that image to create multiple VMs.

我们建议你将单个快照或 VHD 的并发部署数限制为 20 个 VM。We recommend that you limit the number of concurrent deployments to 20 VMs from a single snapshot or VHD.

复制磁盘Copy a disk

创建一个快照,然后根据该快照创建一个磁盘。Create a snapshot and then create a disk from the snapshot. 此策略可以保留原始 VHD 作为回退的依据:This strategy allows you to keep the original VHD as a fallback:

  1. Azure 门户的左侧菜单中,选择“所有服务” 。From the Azure portal, on the left menu, select All services.
  2. 在“所有服务”搜索框中,输入“磁盘”,然后选择“磁盘”以显示可用磁盘列表 。In the All services search box, enter disks and then select Disks to display the list of available disks.
  3. 选择要使用的磁盘。Select the disk that you would like to use. 此时会显示该磁盘的“磁盘”页 。The Disk page for that disk appears.
  4. 从顶部菜单选择“创建快照” 。From the menu at the top, select Create snapshot.
  5. 输入快照的“名称” 。Enter a Name for the snapshot.
  6. 为快照选择一个资源组Choose a Resource group for the snapshot. 可以使用现有资源组,也可以创建新组。You can use either an existing resource group or create a new one.
  7. 对于“帐户类型”,选择“标准 (HDD)”或“高级 (SSD)”存储 。For Account type, choose either Standard (HDD) or Premium (SSD) storage.
  8. 完成后选择“创建”,以便创建快照 。When you're done, select Create to create the snapshot.
  9. 创建快照后,选择左侧菜单中的“创建资源” 。After the snapshot has been created, select Create a resource in the left menu.
  10. 在搜索框中输入“托管磁盘”,然后从列表中选择“托管磁盘” 。In the search box, enter managed disk and then select Managed Disks from the list.
  11. 在“托管磁盘”页上选择“创建” 。On the Managed Disks page, select Create.
  12. 输入磁盘的名称 。Enter a Name for the disk.
  13. 为磁盘选择一个资源组Choose a Resource group for the disk. 可以使用现有资源组,也可以创建新组。You can use either an existing resource group or create a new one. 该选择也将用作在其中根据磁盘创建 VM 的资源组。This selection will also be used as the resource group where you create the VM from the disk.
  14. 对于“帐户类型”,选择“标准 (HDD)”或“高级 (SSD)”存储 。For Account type, choose either Standard (HDD) or Premium (SSD) storage.
  15. 在“源类型”中,确保选中“快照” 。In Source type, ensure Snapshot is selected.
  16. 在“源快照” 下拉列表中,选择要使用的快照。In the Source snapshot drop-down, select the snapshot you want to use.
  17. 根据需要进行其他方面的调整,然后选择“创建”以创建磁盘 。Make any other adjustments as needed and then select Create to create the disk.

从磁盘创建 VMCreate a VM from a disk

有了要使用的托管磁盘 VHD 以后,即可在门户中创建 VM:After you have the managed disk VHD that you want to use, you can create the VM in the portal:

  1. Azure 门户的左侧菜单中,选择“所有服务” 。From the Azure portal, on the left menu, select All services.
  2. 在“所有服务”搜索框中,输入“磁盘”,然后选择“磁盘”以显示可用磁盘列表 。In the All services search box, enter disks and then select Disks to display the list of available disks.
  3. 选择要使用的磁盘。Select the disk that you would like to use. 此时会打开该磁盘的“磁盘”页 。The Disk page for that disk opens.
  4. 在“概览”页中,确保“磁盘状态”列为“未附加” 。In the Overview page, ensure that DISK STATE is listed as Unattached. 否则,可能需要将磁盘从 VM 拆离,或者需要删除 VM 以释放磁盘空间。If it isn't, you might need to either detach the disk from the VM or delete the VM to free up the disk.
  5. 在页面顶部的菜单中选择“创建 VM” 。In the menu at the top of the page, select Create VM.
  6. 在新 VM 的“基本信息”页中输入一个“虚拟机名称”,然后选择现有“资源组”或创建新组 。On the Basics page for the new VM, enter a Virtual machine name and either select an existing Resource group or create a new one.
  7. 对于大小,选择“更改大小”以访问“大小”页 。For Size, select Change size to access the Size page.
  8. 选择 VM 大小行,然后选择“选择” 。Select a VM size row and then choose Select.
  9. 在“网络”页中,可以让门户创建所有新的资源,也可以选择现有的“虚拟网络”和“网络安全组” 。On the Networking page, you can either let the portal create all new resources or you can select an existing Virtual network and Network security group. 门户始终为新 VM 创建新网络接口和公共 IP 地址。The portal always creates a new network interface and public IP address for the new VM.
  10. 在“管理”页上,对监视的选项进行任何更改 。On the Management page, make any changes to the monitoring options.
  11. 在“来宾配置”页上,根据需要添加任何扩展 。On the Guest config page, add any extensions as needed.
  12. 完成操作后,选择“查看 + 创建” 。When you're done, select Review + create.
  13. 如果 VM 配置通过验证,则选择“创建”以启动部署 。If the VM configuration passes validation, select Create to start the deployment.

后续步骤Next steps

也可使用 PowerShell 将 VHD 上传到 Azure 并创建专用 VMYou can also use PowerShell to upload a VHD to Azure and create a specialized VM.