Octopus variable substitution within the step template Deploy an Azure Resource Manager

Hello,

The Azure Resource Manager step template does not provide the feature capability to substitute variables in files like many other step templates do. How would I go about achieving variable substitution using this step template? I’ve read in several places that variable substitution is automatic for the template and parameter files, but I find the substitution is not occurring on the parameter files as I’d hoped. Some secrets are stored in an Azure key vault. Others are intentionally kept from the developers and stored in Octopus variables – hence the desire to perform variable substitution for some Azure environments.

Thanks for your time!
Tom

Hi Tom,

Thanks for reaching out, welcome to the Octopus Community!

That’s correct, variable substitution should now occur automatically for most of our recent step templates such as ‘Deploy an Azure Resource Manager template’ and it’s no longer required to specify the feature under ‘Configure Features’.

Typically, all that should be required for it to work is the use of the OctoStache syntax #{} along with a variable of a matching name.

E.g. I have "name": "#{storage_name}" in my template along with a corresponding variable:

I’d be happy to take a look into why it’s not working on your end, would you be willing to share your Task logs for a deployment that isn’t working? Files can be uploaded securely here, let me know if there are any issues with it at all!

Best Regards,

Thanks for the quick response. I’ve uploaded the verbose task log. Step 1 is particularly relevant in this case. I’m running v2020.6.4671, so maybe this capability was included in a later version.

I’ve also uploaded a snapshot showing the definition of one of the variables that is not being substituted.

Thanks for your assistance!

Hi @ToFoX,

Thanks for uploading the logs, confirming I have received them ok!

I’ve just tested on a local reproduction of 2020.6.4761 and it’s all working as expected on my end… It’s very strange that it’s not working for you!

Would you please be able to configure Variable Logging by adding these variables and send through the new logs for a new release? That will outline how the variable values are being evaluated (it still won’t log any sensitive variables values).

OctopusPrintVariables = true
OctopusPrintEvaluatedVariables = true

Looking forward to getting to the bottom of this, feel free to let me know if you had any questions!

Best Regards,

Okay, I’m embarrassed. It would appear substitution is working fine. The variable scope was simply incorrect in several cases and somehow escaped me. Sorry that I’ve wasted your time. Those 2 debug variables are a good tool to use going forward.

I would like to see variable substitution “enabled” as a forced feature for sake of consistency across step templates. Alternatively, the verbiage within the Deploy an ARM template could be improved to point out that variable substitution will be performed on both template and parameter files. I shouldn’t have to go to the documentation for that.

Thanks for your time!!

Hi @ToFoX,

No problem at all, glad to hear it’s all sorted!

Thanks for the suggestion, I agree that it definitely could be clearer about what’s going on and that’s a great idea to have it shown under ‘Configure Features’ as a feature that can’t be disabled. I’ve passed this over to the relevant team, I know there are a bunch of changes coming to this space so hopefully it will get picked up and added soon.

Please feel free to reach out again anytime you have any questions or feedback about the product, we really appreciate the suggestions!

Happy Deployments!