I have managed to patch settings like CertThumbprint and the ConnectionString by setting environment variables in the following style:



I have tried to follow the same pattern for the InstrumentationKey setting but I'm not seeing the logs appear in AppInsights - if I manually override the default value in sitecorehost.xml, then they do appear.

1 Answer 1


To patch any version of Sitecore Identity server, you should make use of the sitecoreruntime folder.

Within that folder, create a subfolder with the name of the environment you are working on (i.e. UAT). Then create an an environment variable called SITECORE_Environment and give it the same value (i.e. UAT).

Within that sub folder, you can then place an exact copy of sitecorehost.xml and override any settings specific to your chosen environment.

A typical distribution may then be deployed with multiple sub folders within the sitecoreruntime folder. The system will check the value stored within Sitecore_Environment variable and patch over the environment specific settings from within the relevant folder.

i.e. C:\inetpub\wwwroot\your-identity-server\sitecoreruntime\UAT\sitecorehost.xml


If you look at the examples provided in the first link below, they use one less SITECORE in their environment variable then you have in the question.

I just tested setting the environment variables below to "Debug" and can see they have successfully patched the settings:

  • SITECORE_Logging__Serilog__MinimumLevel__Default
  • SITECORE_Logging:Serilog:MinimumLevel:Default

Therefore, please try again but use either of these in your situation:

  • SITECORE_Logging__ApplicationInsights__InstrumentationKey
  • SITECORE_Logging:ApplicationInsights:InstrumentationKey

Further information here:



  • Thanks for the response. My issue with this approach is that the AI resource will need to be created ahead of time and the key checked into source control. Currently I'm provisioning ID via bicep and therefore aiming for an idompotent structure. This is possible using environment variables for Cert info, Conn String etc. But doesn't appear to be possible for AI.
    – djh
    Commented Jan 23 at 9:58
  • Please see updated answer Commented Jan 23 at 10:25
  • Could have sworn I give that a go previously; looking at it now I might have double underscored from the off. Looks to have worked - thanks a bunch!!
    – djh
    Commented Jan 23 at 11:31

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.