Unwanted quotes from substitute variables in files using an output variable

What I am trying to do is automate the process of setting up azure app insights and placing the key into an application’s config.

What I have done is used apply a terraform template to create the app insights in Azure which returns the instrumentation key.

instrumentation_key = a8266dc8-9278-4e58-9117-dd4dc0ee8eb4
Saving variable "Octopus.Action[Create Azure Resources].Output.TerraformJsonOutputs[instrumentation_key]" with the JSON value of "{
    "sensitive": false,
    "type": "string",
    "value": "a8266dc8-9278-4e58-9117-dd4dc0ee8eb4"
Saving variable "Octopus.Action[Create Azure Resources].Output.TerraformValueOutputs[instrumentation_key]" with the value only of ""a8266dc8-9278-4e58-9117-dd4dc0ee8eb4""

In the following step, I use the substitute variables in files feature as part of an app deploy to place the key into the app’s config. The file is called ApplicationInsights.config, the standard file for integrating app insights into a C# app. Substitute variables in files successfully places the output variable into the config but includes unwanted double quotes (").

The config file is like the following:


I have tried using the following template syntax to substitute the output variable after reading this help post about removing quotes. The quotes are added with both template syntax.

#{Octopus.Action[Create Azure Resources].Output.TerraformJsonOutputs[instrumentation_key].value}
#{Octopus.Action[Create Azure Resources].Output.TerraformValueOutputs[instrumentation_key]}

The following is what the resulting substitution looks like (I have removed the key)


Any help would be very appreciated in removing these extra quotes.

Hi Jordan,

Thanks for contacting us. Another option to try removing the quotes is to use the new Replace filter that was added in 2018.8.4.

#{Octopus.Action[Create Azure Resources].Output.TerraformValueOutputs[instrumentation_key] | Replace “\”"}

If that doesn’t work, could you please send the deployment process you’re using, and the scripts that are failing to us?


It’s not solved yet.
I have a variable call test that only have this:
#{each ip in platform_ip}#{ip | Replace “”"}#{/each}
platform_ip is a variable with all Ips in a platform:“”,“”

I tried to replace string “1” to “” and it works, but it does not work working with quotes.

The powershell i’m using is
write-host $test

And it returns #{each ip in ip_platform}#{ip | Replace “”"}#{/each}

The problem is that I need the same variable once with quotes and once without them

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