Mastering Windows Server 2016 Hyper-V

(Romina) #1

Migrating Virtual Machines Between Hyper-V and Azure


IaaS


A huge “better together” factor with Microsoft Azure and Microsoft Hyper-V on
premises is the compatibility aspect of the virtual machines, enabling virtual
machines to be moved between on-premises and Microsoft Azure and back again.
Here are some considerations:


At  the time    of  this    writing,    Microsoft   Azure   does    not support VHDX,   so  your
virtual hard disks should be VHD.
At the time of this writing, Microsoft Azure has a 1,023GB size limit, so keep the
VHD files at 1,023GB or less.
Microsoft Azure supports only fixed VHD files, but dynamic VHDs can be
converted by using the Convert-VHD cmdlet.
Microsoft Azure virtual machines can have only a single network address, and its
IP must be configured using DHCP.
Microsoft Azure is currently based on Windows Server 2012 R2 Hyper-V.
Microsoft Azure does not currently support generation 2 virtual machines; use
generation 1 virtual machines only.

Primarily to move virtual machines, the VHD file(s) for the virtual machine will be
uploaded or downloaded from Microsoft Azure and then a new virtual machine will be
created that uses the VHD file(s). The process to perform an on-premises to Microsoft
Azure migration is as follows:


1 . Upload  the VHD(s)  to  Microsoft   Azure   by  using   the Add-AzureRmVhd  cmdlet. For
example, here I create a test VHD and then upload it:
$sourceVHD = "D:\Temp\vhdtst.vhd"
$destinationVHD =
https://masteringhyperv2016.blob.core.windows.net/vhds/vhdtst.vhd"
New-VHD -Path $sourceVHD -Dynamic -SizeBytes 10GB
Add-AzureRmVhd -ResourceGroupName <RG Name> `
-LocalFilePath $sourceVHD -Destination $destinationVHD `
-NumberOfUploaderThreads 5

2 . The disk    can now be  used    with    a   VM. If  it  was going   to  be  the OS  disk,   it  can be
used with a new VM as follows:
$vm = Set-AzureRmVMOSDisk -VM $vm -VhdUri $osDiskVhdUri ` -name
$osDiskName -CreateOption attach -Windows `
-Caching $osDiskCaching

If  the disk    was to  be  added   as  a   data    disk,   use the following:
Add-AzureRmVMDataDisk -VM $VM -Name $VHDNameShort -Caching None `
Free download pdf