Using Octopus system variables with JSON Configuration Variables feature

I have a .net core deployment that uses JSON Configuration Variables feature. When the appsettings.json contains

{
"Octopus.Environment.Name": ""
}

the value remains empty when I expected it to be populated from https://octopus.com/docs/deployment-process/variables/system-variables

Other normal project variables are substituted in the normal way so I know the feature is working. What’s the best way to put a system setting into my appsettings.json please?

Hi @2caefa61,

Thanks for getting in touch! I’m sorry for the delay in getting back to you here. I have some information which I hope helps you out here.

I do not believe you are able to use System Variables in this method during deployment. Something you could do here is to enable the “Substitute variables in files” feature, then do the following in your config:

{
"Octopus.Environment.Name":"#{Octopus.Environment.Name}"
}

I tested this on my VM, when deploying to Dev environment. The variable in the file was substituted and looked like this:

{
"Octopus.Environment.Name":"Dev"
}

The following documentation page has some more information on the Substitute Variables in Files feature.

Let me know if you have any further thoughts or questions here. :slight_smile:

Best regards,
Daniel

1 Like

Great, thanks for your help! I’ll use the suggested feature.

Hi @2caefa61,

No worries at all! Please do not hesitate to get in touch at any time. :slight_smile:

Best regards,
Daniel

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.