1
votes

Our project is in sitecore and using Azure - App service for deployment. We have created staging slot and apart from application setting and connection string want to make some configuration file slot specific(stick to slot while swapping).

Is there a way to make whole configuration file to stick to a particular slot?

We also tried to write some sitecore configuration in app setting option in azure and ticked it to make it stick to slot but still it is getting swapped.

Please help me on this.

3

3 Answers

1
votes

Is there a way to make whole configuration file to stick to a particular slot?

No, it is not possible (as of date of writing this answer, as azure is evolving all the time).

Here you can see details of slot swap procedure. My rewriting:

  1. Production slot settings applied to staging slot -> site restart
  2. Staging slot warmup
  3. Host names for production & staging slots get swapped.
  4. Staging slot settings applied to (new) staging slot -> (new) staging slot restart

So basically slot setting is really specific feature; other than that slots are just separate sites, with different host names, ftp shares etc.

Any logic like "I want to have file sticked to slot" should be implemented in some custom way.

For example you can consider using config transforms (you can use this question as a start).

0
votes

In the Azure portal you can add AppSettings and mark them as "Slot Specific". These can be read from the application using normal System.Configuration.ConfigurationManager.AppSettings semantics.

There's no way to ask Azure programmatically which slot the app is running in to my knowledge.

0
votes

Alternatively, you can add AppSettings into the Azure Portal's Application Settings and have those setting stick to the slot. These settings will override whatever is in the web.config. For example, if you have an Azure Portal AppSetting of key "Greeting" and value of "Welcome", and the web.config has the same AppSetting with value of "Hello" - the result will be "Welcome". If there is an AppSetting in the web.config that is not in the Azure settings, then it will use the web.config value.

enter image description here