Sitecore 9 : Custom Config Roles & Custom Environment


Sitecore has made the server configuration more simplified way inorder to manage the configuration related to environment and role that the instance would play.

For example, we have the Instance as standalone, CM, CD, reporting also the environment like standalone, DEV, SIT, UAT, PreProd, Prod.

In the above all combination we would be having different configuratino values for each environment and roles such as unicorn sync should happen only Till UAT and not in production and only on ContentManagement or standalone.

Approach 1: use the build transformation to manage the config files on environment and role, but think we need to maintain lot of config files which will he headache in future when we grow the application

Approach 2: manuall edit the config files on instance, this will really easy but difficult to maintain on upgrade, and fixes by others.

Approach 3: Using Sitecore 9 Role and Env Configuration Combinational approach.

How this makes life easy for the developers, release management team.

Changes that required

We need to add the entry in web.config to specify the server Role and Env.

Instance Role and Env
Instance Role and Env

How the setup the Config files,

lets take the sample of the unicorn config file which we suppose to mention the unicorn sync up path that we need to consider, also this config need to be deployed except Production and only on content management servers.
the normal unicorn config file for sitecore will have have the tags in same sequence

How it should be in future.

the above config can be deployed to all the environment and all the instance irrespective of CD, CM, Reporting, or DEv, Uat, prod. but the configuration will be enabled only for Non product and CM or standalone instance only.

Another Example

Consider a scenario where we need to have an API secret key which is different for each environment. in this case we would be creating the build transformation or patch the files manually. here it can be all maintained in single config file with below example

 

In above any 1 key or non will be included in sitecore instance based on server Role configuration value.

We can do a reference on sitecore for details on the same onĀ Sitecore Reference

reach out if you need more help on the same

 

Have any Question or Comment?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discussion Topics