Manage configurations in Continuous delivery pipeline
By default, Sitefinity CMS stores its configuration files in Auto mode. This means that the website configuration are stored in the database, while system settings are saved on the file system to ease making config transformations. For more information about Sitefinity CMS configuration files storage, see Auto-storage mode of configurations.
When setting up Continuous Delivery (CD) pipeline for your Sitefinity CMS website you usually work with multiple environments. For example, code changes get deployed to an Integration environment, then promoted to Staging, and finally to Production. In such setup, the code base does not change, however your website configurations might need to vary to reflect different environment settings, like connection strings, SMTP settings, and so on. While config transformations is one way of handling the need to have different configuration settings for each environment, Sitefinity CMS enables you to leverage Continuous Delivery pipelines environment variables to easily define and manage the transformations for each environment.
Storing configuration values in the web.config AppSetting section
To facilitate managing configuration settings transformations via Continuous Delivery pipelines environment variables, Sitefinity CMS enables you to store configuration setting values in the website web.config <appSettings> section. This is made possible via exposing a specific key for each configuration setting. The key for each configuration can be obtained in the Advanced Settings UI of your Sitefinity CMS website backend. When you add this key in your website web.config <appSettings> section, and set the desired value, Sitefinity CMS starts reading the value from <appSettings> instead of the default location. From this point on you can configure the configuration setting value transformations via Continuous Delivery pipelines environment variables, the same way as any other web.config value.
To start storing a configuration setting value in the web.config <appSettings> section, perform the following:
- In Sitefinity CMS backend, navigate to Administration » Settings » Advanced.
- Navigate to the desired configuration setting.
- Use the Path to configuration property hint, located next to each configuration setting name and copy the path.
- Edit your website web.config file and add a new entry in the <appSettings> section using the following:
- Key: sf-env:pathToConfigurationProperty
- Value: the desired configuration setting value
NOTE: The parameters passed to the environment variable configuration are case sensitive and must be configured using camel case, as displayed in the example below.
- Save your changes to the web.config file.
As a result, your Sitefinity CMS website now reads the value of the configuration setting from the web.config file.
NOTE: Once you use Path to configuration property to store configuration values in the web.config <appSetting> section, you can no longer edit the configuration setting value from the Sitefinity CMS Advanced Settings UI.
Advanced Settings will now display the path to configuration property in the textbox for setting the configuration value along with an informative message that the value of this config settings is defined externally:
This mechanism prevents accidental override of the transformation values defined in your CD pipeline. To reverse this behavior to the default one, you can simply remove the entry from your web.config <appSettings> section.