Bulb Flash: Update Configuration without restarting your webrole

Recently started working on an azure project where we frequently updated a setting in our Service configuration file. Only every time we did that  our web role got restarted…

Then came across this event which can be hooked on to decide if the webrole should be restarted or not.

RoleEnvironment.Changing += RoleEnvironmentChanging;
RoleEnvironment.Changed += RoleEnvironmentChanged;

then handle the Changing Event

private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
{

///Here you can write logic to check the kind of change and decide if you want to cancel the restart…
    if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
    {
        e.Cancel = true;
    }
}

So incase you don’t want your role restarting….this is one solution…we can argue about the pros and cons though!!

Cennest!!