none
azure webrole Global.Application_Start is never called

    Question

  • I created a simple ASP.NET project and then added cloud deployment descriptor using Visual Studio. Once I do that, Application_Start() method in global.asax file never gets called. In my project, I do lot of initialization such as loading web.config file, loading connection strings, initiailizing cache, etc. I can not put all of them into WebRole.OnStart() method. 

    Is there any special configuration required to have Application_Start() method in Global class invoked?

    Thanks,
    Prasanna
    Tuesday, May 22, 2012 5:22 AM

Answers

  • Hi,

    As far as i know, Application_start event will be invoked by Azure application (After OnStart method), please refer to this tutorial:

    http://msdn.microsoft.com/en-us/wazplatformtrainingcourse_introtowindowsazurelabvs2010_topic2#_Toc313609301

    void Application_Start(object sender, EventArgs e)
    {
    Microsoft.WindowsAzure.CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>  
    {    
    configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));
    });
    }

    Do you mean you can not set breakpoints in Application_start code block, but can not see the breakpoints works? If so, i think there's something wrong with the VS or Azure emulators, but the code in Application_Start will be invoked as usual.

    Hope this helps.


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

    Tuesday, May 22, 2012 9:13 AM
    Moderator

All replies

  • Hi,

    As far as i know, Application_start event will be invoked by Azure application (After OnStart method), please refer to this tutorial:

    http://msdn.microsoft.com/en-us/wazplatformtrainingcourse_introtowindowsazurelabvs2010_topic2#_Toc313609301

    void Application_Start(object sender, EventArgs e)
    {
    Microsoft.WindowsAzure.CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>  
    {    
    configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));
    });
    }

    Do you mean you can not set breakpoints in Application_start code block, but can not see the breakpoints works? If so, i think there's something wrong with the VS or Azure emulators, but the code in Application_Start will be invoked as usual.

    Hope this helps.


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

    Tuesday, May 22, 2012 9:13 AM
    Moderator
  • Are you sure that the web role is actually starting properly ? How did your diagnose that the Application_Start is not being called ?

    Be nice to nerds ... Chances are you'll end up working for one!

    Tuesday, May 22, 2012 7:49 PM