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!!

Advertisements

About Cennest
Cennest is the brainchild of a group of IT Professionals keen to try their hand in the world of IT Freelancing. After working in the corpora

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: