本地VHD文件到Azure VM [英] On-Premeses VHD File to Azure VM

查看:126
本文介绍了本地VHD文件到Azure VM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

我需要帮助将VHD配置为Azure VM

我已将VMWare VM转换为VHD,并上传到Azure存储.

我需要逐步指导如何将VHD配置到Azure VM.

解决方案

你好,

  • 将vhdx文件转换为vhd
  • 将vhd文件上传到Azure
  • 将此上传的vhd磁盘附加到VM

使用Azure门户和Windows PowerShell执行这些任务.

请注意,本指南可用于导入包含数据的简单VHD磁盘,或导入虚拟机映像.在这两种情况下,您都必须将VHD磁盘上传到Azure,然后:

  • 将磁盘附加到现有VM
  • 或基于上传的VHD磁盘创建Azure映像.然后,您可以使用该映像创建一个新的虚拟机.如果要将虚拟机上传到Azure,则必须先对操作系统进行系统准备.完成后 自定义设置中,导航到c:\ windows \ system32 \ sysprep并运行 sysprep.exe .使用以下设置运行系统准备:

创建VHD磁盘

首先创建一个VHD磁盘.在此示例中,我将使用磁盘管理实用程序创建本地VHD文件.点击"动作",然后选择"创建 VHD ":

我选择了VHDX来描述如何将VHDX磁盘转换为VHD格式.等待,直到成功创建VHDX磁盘.

接下来,您可以初始化磁盘并格式化分区.打开Windows资源管理器,并确认您可以在磁盘上创建一个项目.

就我而言,我将复制并粘贴SCCM可执行文件.

准备将VHDX导入Azure时,可以分离磁盘.首先,选择"离线",然后选择"

转换VHD磁盘

在将VHDX上载到Azure之前,必须将磁盘转换为VHD格式. Azure不支持VHDX磁盘,因此必须运行以下PowerShell命令来执行此任务:

注意:

  1. 以管理员"身份打开PowerShell控制台
  2. Hyper-V虚拟机管理Windows服务必须正在运行.

我可以确认已成功创建VHD文件:

StarWind Virtual SAN 无需物理共享存储只需在管理程序服务器之间镜像内部闪存和存储资源即可. 此外,该解决方案可以在现成的硬件上运行.这样的设计使StarWind Virtual SAN不仅可以实现高性能和高效的硬件利用率,而且还可以减少运营和资本支出.
详细了解 StarWind 虚拟SAN .

上载VHD磁盘

对于下一步,您必须在工作站上安装 Azure-RM PowerShell模块,因为我们将使用  Add-AzureRmVhd   cmdlet. 此cmdlet将虚拟硬盘从本地虚拟机上载到Azure中云存储帐户中的Blob.打开PowerShell控制台,然后连接到您的Azure订阅:

现在,我们需要创建一个容器,并获取上载VHD磁盘所需的URL.打开您的存储帐户,然后导航到"容器",然后单击"

当您进入存储帐户"时,可以从Azure门户获取URL:

  • 斑点
  • 容器
  • 我是通过Azure资源管理器(ARM)门户完成​​此操作的,但是您还可以通过PowerShell通过创建Azure存储上下文来检索此信息:

    现在,您可以轻松构建URL属性:

    好的,我们准备将VHD文件导入到Azure.使用以下命令:

    根据您的VHD磁盘的大小,您必须稍等一下...

    上传完成后,我可以确认该VHD文件在我的Azure存储中存在.

    对于喜欢使用Azure门户的用户,可以通过单击"上传"来上传VHD磁盘: >

    附加VHD磁盘或创建新的VM

    最后,打开虚拟机"刀片,然后选择"磁盘"以附加上载的磁盘:

    如果要基于上传的VHD磁盘创建新的VM,则需要首先创建一个Azure映像:

    不要误解,只需点击"添加数据磁盘".在这里,我们要创建OS磁盘,而不是数据磁盘!

    最后,将VM映像设置为新VM的源映像.因此,请使用托管VM映像的ID设置源映像:


vm = Set-AzureRmVMSourceImage -VM


vm -Id


Dear Concern,

I need help for configure VHD to azure VM

I have convert VMWare VM to VHD and uploaded in to Azure Storage.

I need guide step by step how to configure VHD to Azure VM.

解决方案

Hello,

  • Convert the vhdx file to vhd
  • Upload the vhd file to Azure
  • Attach this uploaded vhd disk to a VM

Use the Azure Portal and Windows PowerShell to perform these tasks.

Please note that this guide can be used to import a simple VHD disk containing data, or to import a Virtual Machine image. In both cases, you must upload the VHD disk to Azure and then:

  • Attach the disk to an existing VM
  • or create an Azure Image based on the uploaded VHD disk. Then, you can create a new Virtual Machine using this image. If you want to upload a VM to Azure, you must sysprep the OS as a prerequisite. Once you have finished the customization, navigate to c:\windows\system32\sysprep and run sysprep.exe. Run the system preparation with the following settings:

Creating the VHD disk

Let’s start by creating a VHD disk. In this example, I will create a local VHD file using the disk management utility. Click "Action" and select "Create VHD":

I selected VHDX to describe how to convert a VHDX disk to VHD format. Wait until the VHDX disk is successfully created.

Next, you can initialize the disk and format the partition. Open the Windows Explorer and confirm that you can create an item on the disk.

In my case, I will copy and paste the SCCM executable.

When you are ready to import you VHDX to Azure, you can detach the disk. First, select "Offline" and then "Detach VHD":

Converting the VHD disk

Before uploading the VHDX to Azure, you must convert the disk to the VHD format. Azure does not support VHDX disks, so you must run the following PowerShell command to perform this task:

Note:

  1. Open the PowerShell console as "Administrator"
  2. The Hyper-V Virtual Machine Management Windows Service must be running.

I can confirm that the VHD file has been successfully created:

StarWind Virtual SAN eliminates any need for physical shared storage just by mirroring internal flash and storage resources between hypervisor servers. Furthermore, the solution can be run on the off-the-shelf hardware. Such design allows StarWind Virtual SAN to not only achieve high performance and efficient hardware utilization but also reduce operational and capital expenses.
Learn more about ➡ StarWind Virtual SAN.

Uploading the VHD disk

For the next steps, you must have Azure-RM PowerShell module installed on your workstation because we will use the Add-AzureRmVhd cmdlet. This cmdlet uploads a virtual hard disk from an on-premises virtual machine to a blob in a cloud storage account in Azure. Open the PowerShell console, and connect to your Azure subscription:

Now, we need to create a container and grab the URL needed to upload our VHD disk. Open your Storage Account, and navigate to "Containers" and click "+ Container" to create the container:

You can get the URL from the Azure portal when you go into the Storage Account:

  • Blobs
  • Container
  • Containers Properties

I did this through the Azure Resource Manager (ARM) Portal but you also can retrieve this information with PowerShell by creating an Azure Storage Context:

Now, you can easily build the URL properties:

OK, we are ready to import the VHD file to Azure. Use the following commands:

Depending on the size of your VHD disk, you must wait a moment…

Once the upload is done, I can confirm that the VHD file exists in my Azure storage.

For those of you who prefer to use the Azure portal, you can upload the VHD disk by clicking "Upload":

Attaching the VHD disk or Creating a new VM

To finish, open the Virtual Machine blade, and select "Disks" to attach the uploaded disk:

If you want to create a new VM based on the uploaded VHD disk, you will need first, to create an Azure Image:

Do not be mistaken by clicking "Add data disk". Here, we want to create the OS disk, not the data disk!

To finish, set the VM image as a source image for the new VM. So set the source image using the ID of the managed VM image:


vm = Set-AzureRmVMSourceImage -VM


vm -Id


这篇关于本地VHD文件到Azure VM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆