Windows Azure Storage in VB: Not running in a hosted service or the Development Fabric
I'm trying to run an instance of the Azure Blob Storage in the Azure Visual Studio 2010 development environment, but keep getting the following error:
System.InvalidOperationException: Not running in a hosted service or the Development Fabric.
The stack trace is pointing to these lines:
Imports Microsoft.WindowsAzure
Imports Microsoft.WindowsAzure.Diagnostics
Imports Microsoft.WindowsAzure.StorageClient
...
CloudStorageAccount.SetConfigurationSettingPublisher(Function(configName, configSetter) configSetter(ConfigurationManager.AppSettings(configName)))
Dim this_storage_account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString")
...
I'm a little dubious about the first line as it comes from a c# interpretor output of what appears to be a common hack to get around a开发者_如何学Go quirk of the CloudStorageAccount class.
DataConnectionString is set to UseDevelopmentStorage=true
Both the Development Fabric and Development Storage are running in the task bar.
I've tried creating a clean solution to see if this was a configuration issue, but am still getting the same error.
Any ideas gratefully received.
This was extremely dense on my part. I believe that it was because I was running the WebRole through the Visual Studio server, rather than the Development Fabric. It therefore couldn't find the Storage service.
For those that follow:
When viewing your WebRoles in the browser you should note that the functionality associated with Azure (beyond a simple web browser) will not be available unless you run them through the Debugger (F5).
When I encountered this error message it was caused by an obsolete service deployment (from the previous day) that appears to have been shut down only partially - the newly started application had a different port number. The application is in C#, but I'm quite sure it is not a language-related issue.
Simply removing the old processes using the Compute Emulator UI or "csrun /devfabric:shutdown" fixes it.
精彩评论