Search code examples
powershellazureazure-storageazure-virtual-machinevhd

Create VHD locally and restore in Azure Cloud Powershell


I downloaded and ran sysinternals tools Disk2vhd https://technet.microsoft.com/en-us/sysinternals/ee656415

I Created a .vhd of my C: drive and I want to push it to the Azure Cloud

The confusing thing is that I start reading about using PowerShell and Prepping the virtual machine

Install-Module AzureRM.Compute -RequiredVersion 2.6.0   

Well that is fine, but that I need about Sysprep and I'm confused about where to even run this? Am I supposed to first create an empty IaaS VM image in the cloud and then RDP into it and do Sysprep on that new VM in Azure?

https://learn.microsoft.com/en-us/azure/virtual-machines/windows/upload-generalized-managed

When I read this I start to realize that I'm not suppose to do this on my local machine.

When Sysprep completes, it shuts down the virtual machine. Do not restart the VM.

Any good resources ?


Solution

  • Firstly, you need use Hyper-V to create a VM by with your VHD. More information about using a VHD with Microsoft Hyper-V(Locally) please refer to this link.

    Secondly, you could RDP to your VM and execute Sysprep and stop the VM.

    Thirdly, you could upload the new VHD to Azure storage account.