1

Can someone tell me whether it's possible to replace an app setting with an environment variable in Sitecore Managed Cloud? Specifically, we would like to create some rule-based config based on an app setting that changes in each environment.

1
  • Are you on containers or app services?
    – Richard Seal
    Commented Sep 7, 2022 at 17:44

2 Answers 2

3

So i thought i would post the answer to this in case anyone else comes across this problem.

So the Sitecore 10.2 docker images (this is the only version I have verified this against) come with a configbuilder that lets you update app settings using environment variables.

If you look in the web.config you will find the config builder settings

<add name="SitecoreAppSettingsBuilder" mode="Strict" prefix="SITECORE_APPSETTINGS_" stripPrefix="true"
    type="Microsoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Environment, Version=1.0.0.0, Culture=neutral"/>

You can create environment variables with the same name as the appsetting prefixed with SITECORE_APPSETTINGS_ and at runtime the app settings value will be replaced with the one in the environment variable.

-2
  • I am assuming you are familiar with creating rule-based configuration. Sitecore documentation covers this extensively
  • Sitecore have outlined steps you can follow to configure your Managed Cloud instance
  • What you are looking for is creating a custom image where you can define your rule-based configurations. You can store your custom image into AZR that is provisioned as part of the SC managed cloud infrastructure. Then update the docker-images.json file with the new image. Below are the steps:
  1. Build a new version of an image based on an existing Sitecore image.
  2. Push your image to Private ACR. Update the docker-images.json file with the new image.
  3. To change docker-images.json, you must create a pull request to main.
1
  • thanks Julius but that's not what i'm after really. Specifically im interested in how you replace an app setting with an environment variable so i can use that value in my rule based config Commented Sep 7, 2022 at 8:22

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.