When you run your cloud services in Azure, it is possible to change your configuration settings (app settings, number of instances, etc.) whilst your service is running – either via the Azure portal or the service management API.
However, you may want to test how your application responds to these config changes whilst running locally in the Azure emulator, especially if you have some custom handling for the RoleEnvironment.Changing event.
Firstly, run your application (web role or worker role) without attaching the debugger – we will see later how to attach the debugger if required. Once your application is running, locate it in the Compute Emulator – right click the Azure icon in the systray and select ‘Show Compute Emulator UI’. Take note of the deployment ID for your service (the number in brackets after the deployment name).
Next, locate the ServiceConfiguration.cscfg file in the bin folder of your application’s Azure deployment folder :
Make a change to either the role instance count or to one of your configuration settings and save the change.
Open up the Windows Azure Command Prompt and run the following command:
Now the first time you make a change to the configuration, for some reason the emulator will recycle all of your instances (and detach the debugger if you had it attached). If you now make any more changes though, the instances will respond as they would if they were running in Azure.
So it is after you have made the first change, and your role instances have recycled, that you can now attach the debugger to one of your instances. In Visual Studio, select Debug -> Attach To Process, and locate WaWorkerHost.exe in the Available Processes. There should be one for each role instance you have running.
Select one and attach. Now, when making any further changes, you can now debug any custom handling you may have for when configuration changes.