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.
Outputs:
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:
<ApplicationInsights>
<InstrumentationKey>place-key-here</InstrumentationKey>
</ApplicationInsights>
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)
<InstrumentationKey>"example-key"</InstrumentationKey>
Any help would be very appreciated in removing these extra quotes.