1

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?

Community
  • 1
  • 1
sharptooth
  • 167,383
  • 100
  • 513
  • 979

1 Answers1

4

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).

Sandrino Di Mattia
  • 24,739
  • 2
  • 60
  • 65