4
votes

I have an application deployed hosted as Azure Web apps and I want to create multiple environments for it: staging, QA, Live using deployment slots.

I keep all of the apps configurations in web.config and I would like to keep them there. I know that web apps have a configuration section, but I would like to use web.config.

My question is: when swapping between slots, is there a way of ignoring the web.config file so that each slot (environment) keeps it's own configuration file?

Thanks

2

2 Answers

1
votes

There is no way to ignore web.config during swap. When you swap, all files get swapped.

The mechanism to solve this is to use slot settings as described in the doc. That can be used to set the value of App Settings and Connection Strings in a way that overrides what you have in your web.config, and making it a slot setting means it does not get swapped.

0
votes

Short answer no, you would have to replace the web.config in the QA environment with the Live web.config before swapping.

What you probably want to use are the Azure 'Application settings'. An azure application setting overrides a web.config value and can also be configured to stick to that specific deployment slot.

Determine what AppSettings and ConnectionStrings settings in the web.config are specific to the environment, for each environment configure those in the Azure Configuration area and mark them as 'Deployment slot settings'.

For example let's say I had deployment slots for a QA and live environment called QA-Slot and Live-Slot.

In my example I have a specific connection string to the QA database and to the Live database called 'defaultConnection' and let's say for each one of these I have a webApp setting that points to a 'Live' APIUrl and a 'QA' APIUrl.

To set up the connection strings and appSettings using the Azure interface, navigate to your Web App's dashboard, in the vertical navigation on the left, select 'Configuration' under the 'Settings' section and then select 'Application settings' in the horizontal tab.

Set up your appSettings and connection string appropriately and on the Add/Edit dialog there is a checkbox to designate them as a 'Deployment slot setting' that you would check.

After configuring your settings for the Live and QA environment any deployment in Live-Slot points to the 'Live' database and 'Live' APIUrl and any deployment in the QA-Slot points to the QA database and QA APIUrl.