Hello Dan,
From Apollo's (thanks Apollo) post, you can understand that actually the web application and RoleEntryPoint code are running in separated processes.
But you mean reading connection information from ServiceConfiguration.cscfg and not web.config file. Right?
If so, I think registering RoleEnvironment.Changed event in the constructor of the singleton class will be fine. When the class is firstly called, the constructor will be triggered, and a method of the class will be handling the RoleEnvironment.Changed event.
If the configuration is changed, the event handler will be triggered as espected.
However, if you are not explicitly handling
RoleEnvironment.Changing event, the default implementation in the Visual Studio templates restarts on all configuration changes. That means, when the configuration is changed, the instances will be restarted and the memory will be refreshed. Thus, the web
application will restart and constructor will be triggered again just as at the first time - a total restart of the application.
To cancel the restart of instance, I suggset handling RoleEnvironment.Changing as well. Code snippet will be:
void RoleEnvironment_Changing(object sender, Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironmentChangingEventArgs e)
{
e.Cancel = false;
}
Thanks,
Wengchao Zeng
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