4

From Sitecore 9.3 onwards, we noticed that the connection string is using a new attribute configBuilder. Its value is SitecoreConnectionStringsBuilder and if we remove this attribute from an on-premise server it does nothing. so the question here is what is the use of this attribute and what it is?

<connectionStrings configBuilders="SitecoreConnectionStringsBuilder">
 ......
</connectionStrings>

2 Answers 2

6

Configuration builders provide a modern and agile mechanism for ASP.NET apps to get configuration values from external sources. Configuration builders:

  • Are available in .NET Framework 4.7.1 and later.
  • Provide a flexible mechanism for reading configuration values.
  • Address some of the basic needs of apps as they move into a container and cloud-focused environment.
  • Can be used to improve the protection of configuration data by drawing from sources previously unavailable (for example, Azure Key Vault and environment variables) in the .NET configuration system.

Reference - https://docs.microsoft.com/en-us/aspnet/config-builder

From Sitecore 9.3 onwards, the connectionstrings.config file refers to the configBuilder SitecoreConnectionStringsBuilder to provide support for the container and cloud-focused environment. When we look on the web.config, we will find that the SitecoreConnectionStringsBuilder uses the Microsoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder class. This class will read the connectionstring from the environment settings. The config section also defines that the connectionstrings are prefixed with Sitecore_ConnectionStrings_ -

<configBuilders>
<builders>
  <add name="SitecoreAppSettingsBuilder" mode="Strict" prefix="SITECORE_APPSETTINGS_" stripPrefix="true" type="Sitecore.Configuration.FlexibleEnvironmentConfigBuilder, Sitecore.Kernel" />
  <add name="SitecoreConnectionStringsBuilder" mode="Strict" prefix="SITECORE_CONNECTIONSTRINGS_" stripPrefix="true" type="Microsoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Environment, Version=1.0.0.0, Culture=neutral" />
</builders>
</configBuilders>

Since on our local or on-premise servers where we are not using docker, this attribute is not in use so if required we can simply remove this attribute.

1
  • 2
    I took advantage of this feature on-premise in order to simplify our deployments. All the settings like role and connection strings sit in the environment variables. Good to add that the key must be present in the app settings or connection strings to take effect. If the key is missing nothing gets added. Also, using environment variables require an IIS reset. Aug 28, 2022 at 12:27
1

In addition to supporting Docker as Mahendra notes, this enables more secure handling of passwords for PaaS installations:

In a PaaS environment, you can protect your connection strings values by moving the raw connection string value to to the AppService connection string section.

Source: Sitecore Security Guide

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.