Dynamic Variable Interpertation

Hi,

We have been doing a lot of work with dynamic environments and Azure Resource Templates. One of the side effects is a lot of the settings come from the template output. This is fine when using scripts or step parameters, what are problem when it comes to replacing application settings or items in a json template. Is there a way to defer the interpretation of a variable to when the step starts?

Hi Dan,

Thanks for getting in touch. I think there are two main options to achieve this given output variables from a template.

First, you could create project variables mapped to template output variables which could be used in subsequent steps. This would work perfectly with any matching app settings etc. See the attached screenshot for an example.

Second, you could always use the Substitute variables in files feature and insert variable substitution strings in your config files/json files. Something like the following.

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=301880
  -->
<configuration>
  <configSections>
    ...
  </configSections>
  <connectionStrings>
    ...
  </connectionStrings>
  <appSettings>
    <add key="AppSetting1" value="#{Octopus.Action[ArmTemplateStepName].Output.AzureRMOutputs[Foo]}" />
    <add key="AppSetting2" value="#{Octopus.Action[ArmTemplateStepName].Output.AzureRMOutputs[Bar]}" />
  </appSettings>
  ...

or

{
  "Name":"#{Octopus.Action[ArmTemplateStepName].Output.AzureRMOutputs[Foo]}",
  "Something":#{Octopus.Action[ArmTemplateStepName].Output.AzureRMOutputs[Foo]}
}

Hope this helps

Rob