Hyper-V Replication to Azure

5 Nov

I think you’ll agree that you can never have enough backups and the thought of going back to the days of swapping out tapes on a regular basis and storing them in secure off-site locations is hopefully just a distant memory now.

I wont go into the full details of my complete current backup strategy but a recent addition to this strategy proved to be quite straight forward.

This recent addition was the ability to perform real-time (every 15 minutes) Hyper-V replication to Azure. I have previously used Hyper-V replication to keep a copy of all VM’s at a second site but this of course involved lots of quite expensive hardware and licenses that had to constantly be tested and upgraded and was only there in the case of an emergency. So, a much better solution was to have the data copied over to Azure and utilise the power of the cloud only when I needed it, with very little to pay in the interim.

It seems that Hyper-V replication to Azure previously required SCCM but you you can do it straight from Hyper-V, bonus.

The process is really straight forward although there are a few things to bear in mind.

First create your Azure account and then create a Site Recovery Vault

hvr1

Once you’ve done that it will provide you with the wizard of all the additional steps that you need to take:

hvr2

  1. Create Hyper-V Site – Essentially a physical location.
  2. Download a registration key – Expires after 48 Hours.
  3. Download the Provider – The installer for Hyper-V, uses the key above.
  4. Create a storage account – Must have Geo-Redundancy and be in the same region as the vault.
  5. Create Azure virtual network – This is needed for when you decide to failover this VM to Azure.
  6. Create Protection Group – The group of VM’s with similar settings, i.e. replication frequency.
  7. Add virtual machine to protect – Once all the pre-requisites are done, you can then select which VM(s) you want to replicate and set the start time.

Once its all kicked of and done the initial replication you can right click on the VM in Hyper-V manager and select Replication Health:

hvr4

hyper-v-replica

Notes:

  • The maximum disk size that can be replicated is 1TB, if you have disks that are larger than this you will have to break them down in to multiple smaller disks.

hvr3

However, I had a disk that was exactly 1TB and this was too large, so it looks more like a less than rule, than a less than or equal to. The solution to this was to shrink the partition with in windows and then shutdown the machine and edit the disk, only then will you have the option to Shrink the disk, I also had shadow copies enabled on this disk.

  • If like me, you remove and re-install the software and registration key you may get an issue that a server is already registered in a Vault. The trick here is to delete the registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Azure Site Recovery 
  • If you need to manually stop and remove VM replication for a VM on Hyper-V, run the PowerShell below:
$vmName = "SQLVM1"
$vm = Get-WmiObject -Namespace "root\virtualization\v2" -Query "Select * From Msvm_ComputerSystem Where ElementName = '$vmName'"
$replicationService = Get-WmiObject -Namespace "root\virtualization\v2"  -Query "Select * From Msvm_ReplicationService"
$replicationService.RemoveReplicationRelationship($vm.__PATH)

It’s also worth nothing that you can throttle this replication from within the Microsoft Azure Backup software on your Hyper-V host. Navigate to “Change Properties” and then select the “Throttling” tab:

azure_hyper-v_throttle

References: