Migrating a Hyper-V Virtual Machine to Azure

Posted 11 January 2017 12:00 AM by Cristian Zaragoza, Senior SharePoint Developer @ ClearPeople

In the last few weeks I’ve been working on a study of how easy or hard it would be to migrate a whole SharePoint farm built on Hyper-V Virtual Machines to Azure IaaS. I must begin with saying that I’m not an infrastructure expert, as in my daily work I’m focused on SharePoint development stuff, but I’ve played a bit with Azure in the past, and specially, managing Azure from PowerShell scripts, as I’m a PowerShell Script lover.

So, my first attempt/test, was trying to move just an all-in-one SharePoint Virtual Machine used for development, and it was quite easy. Below you can see the steps I followed. Bear in mind that we are using the cmdlets related with Azure Resource Manager modules which corresponds to portal.azure.com.

Step 1 - Logging into Azure:

Step 2 - The AzureRM-related cmdlets needs to be set with which Azure subscription we are going to operate, in case we have more than one. To do so, we need to select the correct one running the following statement:
Get-AzureRmSubscription -SubscriptionName "Visual Studio Enterprise" | Select-AzureRmSubscription

Step 3 - Next step is to upload the VM to Azure as a blob. Before being able to do that, we need to know that Azure IaaS only supports VHD files, not VHDX files. So, I had to convert my VHDX Virtual Machine to VHD. Fortunately, there is a pretty straightforward cmdlet to do that. It can take some time, depending on the size of the VM.
Convert-VHD -Path “C:\SP2013Dev.vhdx” -Destination-Path “C:\SP2013Dev.vhd”

Step 4 - Once that we have our VM as a VHD file, we are ready to upload it to Azure as a BLOB. Before doing that, we need to know which Resource Group we are going to use, plus the Storage Account container where we are going to place the BLOB.
$resourceGroupName = "cmzg-resource-group"
$sourceVhd = "C:\SP2013Dev.vhd "
$destinationVhd = "https://cmzg.blob.core.windows.net/vhds/SP2013Dev.vhd"
Add-AzureRmVhd -LocalFilePath $sourceVHD -Destination $destinationVHD
-ResourceGroupName $resourceGroupName -NumberOfUploaderThreads 5

Again, this can take some time depending on the file size, and also your broadwidth. Once the uploading is completed, you will see the BLOB file in your Storage Account.

Step 5 - The next and final step is to create a new VM based on our just uploaded VHD file. This step, involves in turn other steps that I’m going to describe. At the end, creating an Azure VM though PowerShell feels like creating different pieces of a puzzle to finally mix them all together.

a. Network Interface and Public IP address
$virtualNetworkName = "cmzg-virtual-network"
$locationName = "North Europe"
$virtualNetwork = Get-AzureRmVirtualNetwork -ResourceGroupName $resourceGroupName -Name $virtualNetworkName

$publicIp = New-AzureRmPublicIpAddress -Name "SP2013Dev-IP" -ResourceGroupName $ResourceGroupName -Location $locationName -AllocationMethod Dynamic

$networkInterface = New-AzureRmNetworkInterface -ResourceGroupName $resourceGroupName -Name "SP2013Dev-NIC" -Location $locationName -SubnetId $virtualNetwork.Subnets[0].Id -PublicIpAddressId $publicIp.Id

b. Finally, we can start creating the VM, but first we need to know what VMSize we are going to use. We can list all the available options:
Get-AzureRmVMSize $locationName | Out-GridView

c. Now we are ready to configure the VM using the New-AzureRMVMConfig cmdlet:
$vmConfig = New-AzureRmVMConfig -VMName "SP2013Dev-Config" -VMSize "Standard_DS1"
$vmConfig = Set-AzureRmVMOSDisk -VM $vmConfig -Name " SP2013Dev-OSDisk" -VhdUri $destinationVhd -CreateOption Attach -Windows
$vmConfig = Add-AzureRmVMNetworkInterface -VM $vmConfig -Id $networkInterface.Id

d. And now that we have all the pieces, last step is just to create the virtual machine. This operation can take a while, but you can see the progress through the Azure Portal.
$myVM = New-AzureRmVM -VM $vmConfig -Location $locationName -ResourceGroupName $resourceGroupName

And that’s all! Just wait a few minutes, and you should be able to access to your virtual machine using the same domain and account you were using on-premise.

Do you want to know more about Microsoft Azure or do you have any other questions? Please feel free to get in touch with us.


Add your comment





intranet Modern SharePoint teamwork employee engagement digital workspace SharePoint JavaScript Windows Azure Digital Transformation staff satisfaction productivity Microsoft Teams Office 365 Yammer cms content management system agile GDPR Microsoft Graph collaboration Microsoft sharepoint 2016 upgrade migration SharePoint Online 2016 Tech Trends Digital Disruption Context marketing marketing SharePoint 2010 SharePoint 2013 TFS Git security kentico Analytics jquery QA Quality Assurance testing content management websites Sitecore sitecore marketplace sitecore module cloud Microsoft Cloud Storage digital strategy technical consulting sitecore modules Experience database Sitecore 7 Sitecore 8 support account management customer experience Data Storage cms integration front end front end development prototype Cloud Storage StorSimple Front-end Development Layout SharePoint 2013 colour palette UI design website design log viewer sitecore cms website Azure big data business-critical sharepoint accessibility android apple chrome clear people clearpeople debug emulator ios mobile testing opera resize adobe desktop flash ie10 internet explorer 10 metro windows 8 bcsp Advanced System Reporter reporting framework ControlMode form control master page placeholder publishing console SharePoint 2007 SharePoint error search search results search values software testing testing scenario audit content information architecture retention schedules PowerShell QuickLaunch scripts SharePoint server 2010 business solutions metalogix replication replicator storagepoint stena technet UK Technet picture library slideshow web part RTM released to manufacturing caml caml query MOSS 2007 query infopath