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.
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:
Production slot settings applied to staging slot -> site restart
Staging slot warmup
Host names for production & staging slots get swapped.
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).
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.
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.
Related
I have a preprod slot on azure web app that is swapped to production slot.
It has same configuration that production slot will have except redirectUrl.
I am using azure devops pipelines to automate the process.
I need the redirectUrl in prepod slot to have different value to verify application working before swapping.
How to have a slot specific setting for a slot that is being swapped to another slot?
I want to avoid one setting being swapped.
Here are the settings that change when you swap slots.
Settings that are swapped:
Settings that aren't swapped:
To configure an app setting or connection string to stick to a specific slot (not swapped), go to the Configuration page for that slot. Add or edit a setting, and then select deployment slot setting. Selecting this check box tells App Service that the setting is not swappable. You could also refer to Which settings are swapped for more information.
I have created multiple slots(test, stage and prod) in my azure app service. Similarly I have created respective web.config files for each environment. I am deploying my application through octopus deployment tool in test environment slot, so initially it's picking web.test.config file and it's working fine.
But, I want to swap complete transformation section of web.config file when I swap it to stage or Prod slot while doing swapping through azure portal. Is there any way to do ?
using application setting and connection string of configuration setting, I am able to segregate the setting of each slot. But I am not sure how can I do it for other section like system.identityModel,system.web system.identityModel.services, etc. Therefore I want to replace complete transformation section according to environment while doing swapping.
When I talked with the app service team, they said slots are not meant for this purpose. The main purpose of slots is to allow deployment of new versions with little or no downtime. Or to test new features with a small percentage of the traffic. Not really for different environments, you should use have separate app services for that, to which you deploy separately.
I would like to start using the deployment slots in my Azure App Services for a staging to production task. The problem that I am running into is I can't seem to find a way to do transformations on the web.config outside of the appsetting and connectionstrings. I seem to be missing something, but I need to be able to adjust other configurations, from logging levels, to other integrated config sections.
We currently have been using direct deployments from our build server with msdeploy and Parameters.xml file to do much of this work, however that won't work with deployment slots.
When you create the additional deployment slot, you can clone all settings from the existing instance, or dont copy anything. As per documentation:
"You can clone configuration from any existing slot. Settings that can
be cloned include app settings, connection strings, language framework
versions, web sockets, HTTP version, and platform bitness."
In the new deployment slot, under Settings > Configuration, you can specify any settings here to be specific to the new deployment slot by selecting "Deployment slot setting".
I do realize I can use Azure AppSettings to override settings in Web.Config files.
https://learn.microsoft.com/en-us/azure/app-service/web-sites-staged-publishing says:
App settings (can be configured to stick to a slot)
Connection strings (can be configured to stick to a slot)
So far so good.
But how do I version these settings?
I don't want to add them manually through the Azure Portal.
Also I don't exactly understand why I can add custom application settings in the Azure App Service release pipeline task. These settings are then copied to the configured slot. Consider following scenario...
There is a new appsetting (which would usually live in Web.Config).
Okay Web.Config is not a good idea because it is specific per deployment slot. So you add it to the release task configuration - for your "staging" slot.
Next you swap staging and production - and of course the new production system has no clue about the new setting (not even the staging configuration which would anyway be equally bad).
I'm using the Microsoft app service to deploy my web application,
and it have staging.domain.com and www.domain.com,
but now they are both link to the same redis,
How to I let them link to different redis, when I swap them?
I think it can solved by the app setting.
Is there any best solution or suggestion?
As shown here in the documentation, you can set different settings on different deployment slots in Web Apps, and set them "sticky". That will make them stay in the deployment slot. If you don't mark them sticky, they will swap with the app.
To configure an app setting or connection string to stick to a slot (not swapped), access the Application Settings blade for a specific slot, then select the Slot Setting box for the configuration elements that should stick the slot. Note that marking a configuration element as slot specific has the effect of establishing that element as not swappable across all the deployment slots associated with the app.