Manage configurations in CD 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:

  1. In Sitefinity CMS backend, navigate to Administration » Settings » Advanced.
  2. Navigate to the desired configuration setting.
  3. Use the Path to configuration property hint, located next to each configuration setting name and copy the path.
    Path
  4. Edit your website web.config file and add a new entry in the <appSettings> section using the following:
    1. Key: sf-env:pathToConfigurationProperty
    2. 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.

  5. 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:

ExternallyDefined

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.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?