#HyperV Prevented Starting Virtual Machine Because it is Prepared For Failover #AzureSiteRecovery #ASR

Hello folks,

I was recently cleaning my Azure Site Recovery failover demo at the Azure ITCamp and I hit the following error:

An error occurred while attempting to start the selected virtual machine. Hyper-V prevented starting virtual machine because it is prepared for planned failover. Virtual machine can be started after cancelling failover preparation”.

HyperV-ASR-StartVM-02

Now before I start with the root cause and the solution of this error, here is what my demo looks like:

– Single Hyper-V host registered with Azure Site Recovery Vault.
– Single Hyper-V site to group one or more Hyper-V servers located in a physical location.
– Single Protection group to group together virtual machines that have common protection requirements.
– Two tier application (VMs) protected with ASR (Back-end SQL database and front-end web server).
– Single Recovery Plan to shutdown and startup virtual machines in sequence as the following: (Shutdown: 1- Web Server / 2-SQL DB – Startup: 1-SQL DB / 2- Web Server).

During my demo, I initiated a planned failover which took around 34 minutes…

If you want to know what Azure Site Recovery does behind the scene, here is the job details:

HyperV-ASR-StartVM-09

As you can see, the planned failover completed successfully!

During the planned failover process, I lost network connectivity between my Hyper-V site and Azure, what I ended up with a Virtual Machine on-premises with “Prepared for planned failover”.

HyperV-ASR-StartVM-04

HyperV-ASR-StartVM-05

The virtual machines are in off state, because Azure Site Recovery during the planned failover operation will initiate a final synch before shutting down the VMs on-premise.

If you are familiar with Hyper-V Replica technology, ASR use the same technology.

During the cleaning process, I started deleting the virtual machines and Hyper-V server from the Azure Site Recovery portal without paying attention on the status on–premise, this causes the VM not to start because it’s still in prepared for failover state, however the failover to Azure was completed.

HyperV-ASR-StartVM-01

There is no option to remove the replication for this VM from Hyper-V Manager, because when a VM is protected using ASR, all the operations must be done from the Azure Site Recovery portal and not from Hyper-V Manager.

What about PowerShell…

HyperV-ASR-StartVM-06

The error is a little bit different here… The operation not allowed because the virtual machine is replicating to a provider other Hyper-V.

Who is the other provider? … ASR of course… The UI error was more precise in this case.

Now in order to manual unregister the Hyper-V server and disable the protection, you want to run the following script on the Hyper-V server where the VM reside.

HyperV-ASR-StartVM-07

This script will remove the old Azure Site Recovery Provider and all related settings on the server.

After removing Azure Site Recovery Provider from the server, we need to clean up the protection settings for the VM manually.

On the source affected Hyper-V host server, to remove replication for the virtual machine use this script. Replace $vmName with the name of your virtual machine.

HyperV-ASR-StartVM-08

This script will remove the replication settings for the affected VM by querying the WMI Namespace “root\virtualization\v2“, then query the “Msvm_ReplicationService” class and remove the replication relationship.

The VM will start now and the replication is manually removed Smile

HyperV-ASR-StartVM-10

Reference: Azure Site Recovery Documentation.

Hope this helps!

Enjoy your weekend…

Cheers,
-Charbel

About Charbel Nemnom 310 Articles
Charbel Nemnom is a Microsoft Cloud Consultant and Technical Evangelist, totally fan of the latest's IT platform solutions, accomplished hands-on technical professional with over 15 years of broad IT Infrastructure experience serving on and guiding technical teams to optimize performance of mission-critical enterprise systems. Excellent communicator adept at identifying business needs and bridging the gap between functional groups and technology to foster targeted and innovative IT project development. Well respected by peers through demonstrating passion for technology and performance improvement. Extensive practical knowledge of complex systems builds, network design and virtualization.

Be the first to comment

Leave a Reply