Azure applications, may have a set of parameters associated, this allows you to change your app configuration without having to redeploy the entire package (a long operation in any case).
You can control how an application reacts to a parameter modification by subscribing RoleEnvironment.Changing event, if you want to restart the whole role when a parameter change you can simply set Cancel=true inside Changing event:
RoleEnvironment.Changing += (s, e) =>
{
e.Cancel = true;
};
in this case, when application’s .cscfg file content change, the role is shut down then restarted so that new parameters can be properly reloaded. If you don’t want to restart the role but handle modifications yourself you can handle Changes parameter passed to RoleEnvironment.Changing event.
How can you test this logic when your app runs inside Azure local compute emulator? here are basic step:
- Run you app locally and read what is current development id by opening compute emulator UI and reading what between parenthesis (2103 in following example) following deploymentXX label:
- Run Windows Azure Command Prompt and navigate to the folder that contains your configuration file ServiceConfiguration.cscfg and run this command:
csrun /update:[id];ServiceConfiguration.cscfg
And you’ll see your role reacting to configuration change appropriately.