Question

In my Azure role I want to mount a VHD - roughly have an equivalent of the following diskpart commands:

vdisk select VhdFilePath
vdisk attach

This answer explains how to create a script and then programmatically invoke it from C#.

Is there a way to achieve the same without a script - just with some .NET classes?

Was it helpful?

Solution

I don't know if there's a managed API to do this, but there are a few examples of C# wrappers around some native methods:

http://www.jmedved.com/2009/05/open-and-attach/

And since this wraps around the AttachVirtualDisk method I assume it should also work for Windows Server 2008 R2 (note that you'll need to set the osFamily of your role to 2 in order to get the R2).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top