I have a web application that is hosted on Azure.
There are currently a few web sites that are using the same code which is retrieved from bitbucket.
The only difference between the various installations is that they have a different connection string in the web.config
files that targets different databases.
Whenever I am making a bug fix I upload my new code on bitbucket and Azure gets this code from BitBucket.
There are currently 5 applications that get the same code and each time I upload new code on bitbucket I have to manually edit the web.config
file on Azure in order to target the correct database for each app.
Is there a way to instruct Azure not to overwrite the web.config
file when It receives new code from Bitbucket?
On possibility is to not version
web.config
, but a template fileweb.config.tpl
, and a value file (with values for each applications)Then, you can use a content filter driver, using
.gitattributes
declaration.(image from "Customizing Git - Git Attributes", from "Pro Git book")
The generated actual
web.config
remains ignored (by the.gitignore
).That means your actual working tree does not get "dirty".
The smudge script selects the correct value file and generates the correct
web.config
based on the template the smudge script is applied on during agit checkout
.The responsibility to change settings based on the website you are deploying could be in the release. VSTS supports releasing software from a source like BitBucket to Azure. Create a VSTS account. Create a project within the account. Create a new build and configure BitBucket as source. Create a release to deploy the webapplication to each of the five places. Use the variables to set a different connectionstring for each webapplication.
Why don't need to hardcode connection strings in
web.config
at all. Just pick it up in your code from Application Settings.From https://azure.microsoft.com/en-us/documentation/articles/web-sites-configure/:
Application Settings/Connection Strings defined in the Portal will override the values from
web.config
/app.config
at runtime.