Skip to content
Mike Larah By Mike Larah Software Engineer III
Azure From The Trenches: Updating Service Configuration Whilst Running In The Emulator

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 :

<YourCloudApplicationPath>\bin\<Debug/Release>\ServiceConfiguration.cscfg

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:

csrun.exe /update:<deployment-id>;"<service-configuration-file-path>"

e.g.

csrun.exe /update:1285;"C:\Projects\YourCloudApplication\bin\Debug\ServiceConfiguration.cscfg

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.

AttachToProcess

Select one and attach. Now, when making any further changes, you can now debug any custom handling you may have for when configuration changes.

@MikeLarah

Sign up to Azure Weekly to receive Azure related news and articles direct to your inbox or follow on Twitter: @azureweekly

Mike Larah

Software Engineer III

Mike Larah

Mike is a Software Engineer at endjin with almost a decade of experience in solving business problems with technology. He has worked on a wide range of projects for clients across industries such as financial services, recruitment, and retail, with a strong focus on Azure technologies.