Skip to content
Mike Evans-Larah By Mike Evans-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.

Azure Weekly is a summary of the week's top Microsoft Azure news from AI to Availability Zones. Keep on top of all the latest Azure developments!

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

Power BI Weekly is a collation of the week's top news and articles from the Power BI ecosystem, all presented to you in one, handy newsletter!

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 Evans-Larah

Software Engineer III

Mike Evans-Larah

Mike is a Software Engineer at endjin with over 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.