Migrate Hyper-V VM to Azure

David Downing 706 Reputation points
2023-02-07T17:20:38.16+00:00

I am trying to use the Hyper-V WMI APIs to prepare a Hyper-V VM for migration to Azure. I am developing a .Net console application to do the tasks.

I started prototyping from this sample code: https://learn.microsoft.com/en-us/windows/win32/hyperv_v2/exporting-virtual-machines, however the code doesn't seem to provide all the details needed to run it.

There are references to a Utility class that are not included in the sample: Utility.GetServiceObject(scope, "Msvm_VirtualSystemManagementService");

The referenced C# utilities can be found in Common utilities for the virtualization samples (V2), don't have the code for this utility class.

In addition; I'm not seeing the WMI Objects/Classes on my local computer. More specifically, the 'ExportSystemDefinition' method.

I'm running Windows 10 Professional.

Windows for business Windows Client for IT Pros Storage high availability Virtualization and Hyper-V
0 comments No comments
{count} votes

Accepted answer
  1. Limitless Technology 44,746 Reputation points
    2023-02-09T09:09:02.56+00:00

    Hi. Thank you for your question and reaching out. I’d be more than happy to help you with your query

    The code you are referring to is a part of the Hyper-V virtualization sample. The missing "Utility" class is likely a utility class provided by Microsoft that's used in the sample to simplify the WMI usage. You can download the full sample from the Microsoft website:

    https://docs.microsoft.com/en-us/windows/win32/hyperv_v2/virtualization-samples-v2

    Alternatively, you can create your own implementation of the utility class based on the WMI classes required for your application. To access the WMI objects and classes, you need to add a reference to the "Microsoft WMI Code Creator" in your .Net project. The "ExportSystemDefinition" method is part of the "Msvm_VirtualSystemManagementService" WMI class. You can access this class using the WMI management API in your .Net application.

    If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.