HRESULT=D0000033 When calling CloudDrive.Mount

I’ve been working with Azure’s new CloudDrive capability, and today I ran into a problem with caching that I thought I would share the workaround for.

The first step in using caching with CloudDrive is to define a LocalResource for the role in the csdef file:

    <LocalResources>
<LocalStorage name="AzureDriveCache" cleanOnRoleRecycle="false" sizeInMB="8000" />
</LocalResources>

Next, you need to initialize CloudDrive caching thus:

 var localResource = RoleEnvironment.GetLocalResource("AzureDriveCache");
CloudDrive.InitializeCache(localResource.RootPath, localResource.MaximumSizeInMegabytes);

And finally, mount your drive:

 var driveLetter = cloudDrive.Mount(4000, DriveMountOptions.None);

And this is when the problem comes up.  Doing this will result in an exception: HRESULT=D0000033 When calling CloudDrive.Mount

Through logging, I see that the RootPath property above was returned as:

C:\Resources\directory\d15989a9895847ee9672b0f217f427bf.XWorkerRole.AzureDriveCache\

After consulting with the Azure team, I learned that there is a bug in the current SDK, and that the trailing ‘\’ character is the cause of the error.

Remove it, and you’ll be fine.