Microsoft.WindowsAzure.StorageClient.CloudDriveException was unhandled by user code Message=ERROR_UNSUPPORTED_OS

I had my Windows Azure SDK 1.2 based ASP.NET application
which was working fine in which I use a cloud drive within the Web role. I
decided to upgrade the exact same application using Windows Azure SDK 1.3 and
while testing it on cloud, immediately I hit the following error:

Microsoft.WindowsAzure.StorageClient.CloudDriveException
was unhandled by user code Message=ERROR_UNSUPPORTED_OS

Source=Microsoft.WindowsAzure.CloudDrive
StackTrace:at
Microsoft.WindowsAzure.StorageClient.CloudDrive.InitializeCache(String
cachePath, Int32 totalCacheSize)

I kept trying and I found the problem is intermittent
and does not happen 100% of the time. Because my application was working fine
with Windows Azure SDK 1.2 I decided to run my Windows Azure SDK 1.3 based
application in legacy mode or in HWC mode. I commented the <Sites>
section in ServiceConfiguration.cscfg. file and uploaded the package again. The
results were same and the problem occurred same way as with Full IIS. I tried
couple of times and the error "ERROR_UNSUPPORTED_OS" was intermittent with HWC
mode as well.

At least now I had a theory that this problem may be
related with CloudDrive Service which may not be available when the role
started and made a CloudDrive call. I decided to RDP to my Windows Azure VM to track this
issue internally. During investigation I found that the problem was actually
related with the timing between Azure CloudDrive Service which is started by
the Windows Azure OS however the role is started by WinAppAgent.exe process.

Further investigation shows that the problem could be
related with following CoudDrive API as well:

- CloudDrive.Create()

CloudDrive.Mount()
  • CloudDrive.InitializeCache()
  • CloudDrive.GetMountedDrives()

The Windows Azure Team do know about this issue and
suggested the following workaround:

We recommend working around the issue by retrying the first CloudDrive API your service calls. The following is an example of code that retries the CloudDrive.InitializeCache()operation. 

For (int i = 0; i < 30; i++)

{

       try

       {

           CloudDrive.InitializeCache(localCache.RootPath,localCache.MaximumSizeInMegabytes);

           break;                  

       }

       catch (CloudDriveException ex)

       {

           if (!ex.Message.Equals("ERROR_UNSUPPORTED_OS") || i == 29)

                 throw;

           Thread.Sleep(10000);

       }

}

https://blogs.msdn.com/b/windowsazurestorage/archive/2010/12/17/error-unsupported-os-seen-with-windows-azure-drives.aspx