Programmatically updating cscfg for Azure Cloud Service

790 views Asked by At

Does anyone know if this is possible - and if so how it can be done? I need to be able to update the settings stored in the .cscfg file on a fairly regular basis and wondered whether this can be done from code. i.e. Without uploading a new .cscfg file to Azure each time. Many thanks

1

There are 1 answers

0
Gaurav Mantri On BEST ANSWER

Configuration file changes are accomplished via Change Deployment Configuration REST API operation, so it is possible to update the config file programmatically. Do take a look at Azure Management Library or Azure PowerShell Cmdlets as both of them have implementation for this operation. However you can't update just one config setting by this operation. You would need to download the config file, update the setting and then reupload the config file through this operation.

Now I realize that messing with XML file can be error prone. What you could do is create an application which parses this configuration file and present various elements of the XML file in an easy to use UI (do take a look at how it is done in Azure Portal). Once you have made the changes, you can recreate the XML file from the data and then reupload the file. However please note that with this, you won't be able to add new settings. To add new setting, the setting must be added in both cscfg and csdef file and for that you would have to redeploy your application.