Try fast search NHibernate

19 July 2011

Azure Storage initialization

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:

public override bool OnStart()
    // For information on handling configuration changes
    // see the MSDN topic at
    RoleEnvironment.Changing += RoleEnvironmentChanging;


    return base.OnStart();

private static void WaitForRoleAvailability()
    bool accountAvailable = false;
            accountAvailable = true;
        catch (RoleEnvironmentException e)
    } while (!accountAvailable);

And for the initialization:


Today the error is away from us… but I would know if you know something better.


  1. Hola Fabio, yo estuve junto a gente de irsa buenos aires en una charla que diste, como puedo hacer para enviarte unas consultas?

  2. Me mandas un mail.
    Mi mail es publico en varios lados, fijate en la lista de nhusers, nh-hispano, alt-net etc. etc.