Click here to Skip to main content
15,892,059 members
Articles / Hosted Services / Azure

How to Access Blob Storage from an Azure Web Site

Rate me:
Please Sign up or sign in to vote.
3.40/5 (3 votes)
7 Jan 2016CPOL2 min read 9.4K   4   1
We recently encountered the dreaded 'Not running in a hosted service or the Development Fabric' yellow screen of death whilst developing a client website hosted inside Azure. This post outlines one approach to accessing Blob/Table/Queue Storage services from an Azure Web Site.

I've read a few posts on this error but they've mainly been focused on the development environment, rather than the production environment that I was encountering the issue on. Our scenario is one in which we have discovered the wonders of Git Deploy and the massive time saving association (kudos to Kudu and David Ebbo et al.) that comes with using an Azure Website as opposed to a Web Role within a Cloud Service (a good comparison of the available options can be found here).

Enter Blob Storage, Exit Working Website

Everything was going well until we brought Blob Storage into the equation. The site was running fine locally, the Azure Compute and Storage emulators had been spun up by Visual Studio running as Administrator, so no problems there. Another speedy git deployment (not that I'm a fan or anything) and then wallop. 'Not running in a hosted service or the Development Fabric' when trying to access CloudConfigurationManager.GetSetting. Some general Googling and reading various Stack Overflow posts lead me to the understanding that an Azure Website is effectively Shared Hosting, and as such doesn't run as a dedicated hosted service. There's no ServiceDefinition config so no direct way to access Blob Storage.

By changing the Web Role to be a WCF service purely focused on reading from and writing to Blob Storage instead of the Azure Website as we initially had it set up before getting on to the Git Deployment goodness, we could abstract the communication with Blob Storage away from the Website. It's still painful to publish the WCF Web Role, so we'll probably make use of the Web Accelerator for Web Roles, a useful project on Github.

To sum up, Azure Websites are great for getting a site spun up and deployed quickly provided that you don't need to use Blob/Table/Queue storage, which requires either a Web Role or a site hosted within an Azure VM. Communication with SQL Azure is fine from a Website as it's just a bog standard connection string. In our scenario, a Web Role hosting a WCF service works just fine.

View original article

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead Levelnis Ltd
United Kingdom United Kingdom
Follow along my journey as I create a newsletter about launching websites. Just message me with "I'm in" and I'll add you

Comments and Discussions

 
QuestionGood job Pin
Isabella19935-Jan-16 5:55
Isabella19935-Jan-16 5:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.