Search code examples
azureconfiguration-filesazure-configuration

Azure Cloud Service Shared Settings File


We currently have an asp.net website and windows service with a separated config file with custom sections in for each pluggable project in our solution. The files are loaded based on the machine name and the configured customer so if the machine is called machine-01 it goes to a folder called machine-01 and if the customer name is customer-01 it tries to find a file in that folder for customer-01.config. This has worked well for us as each development machine has it's own configuration files and we can create a config file for a customer and save it in TFS.

However now we are looking to also host our site in Azure Cloud Services for most of our customers although one or two host the application on their own infrastructure which is standard windows server, IIS, etc.

Our deployment procedures are not ideal, it involves manually copying the application and manually running Sql scripts. We are now moving away from this, we are starting to look at FluentMigrator and we want to get to the point we have a single deployment package for a version of our application for Azure and for self hosted.

I am happy to change/re-write as much as possible but in an ideal world I would like to get to the point of a single settings file that is made available to a web and worker role containing all the settings that is not deployed with the app but is set up in azure for that service as these settings will not change. At the same time continuing for non azure deployments to use our custom configuration files.

Is it possible to upload a settings file in this way to an azure cloud service and simply load that file on start-up for the web and worker roles?

As I said, happy to re-write as much as needed here for the best solution so happy to throw out what we have in favour of the ideal solution. Many thanks for any input/suggestions.


Solution

  • Having gone through a not dissimilar exercise, your problem is really about the location of your configuration data and that the settings file just isn't dynamic enough for your requirements. Therefore you need to look at another storage mechanism, i.e. SQL Db or Azure Table Storage, that stores all the appropriate config data your application requires and load this either at the role start or web site application start. BTW - you cannot gracefully get the WebRole to communicate to the WebSite, its possible but messy.

    We originally looked at changing the web.config dynamically on the site but this causes a whole heap of trouble on the Azure Platform, which appeared possible but has certain concessions. FWIW here's what I originally followed but went with using ASP.NET data caching and loaded up the configuration settings at the Application_Start.

    HTH