More than a post about “how initialize the Azure storage” this is a “bottle to sea” to check if somebody else known a best-practice, a recommendation or whatever you call it.
In the past year we had experimented the very nice and useful exception starting our Web-Role… if you have an application on Azure I’m pretty sure you saw it too:
Very nice and informative, even better than some of our exceptions in NHibernate.
The matter is that at some point you need the CloudStorageAccount and, at some point, you have to initialize the storage. We thought that the better place to initialize the storage is the HttpApplication.Application_Start() but… error; then we have tried the WebRole class and again… error. With no lucky I have tried to find some guideline about where initialize the storage, then I have opted for a “lazy initialization” at the first time an action with the storage is required but, again… error!!
Today I tried a new solution and hopefully it is the final-cut to the story. Here is the code:
And for the initialization:
Today the error is away from us… but I would know if you know something better.