Using Output parameter in an Azure Resource Group Template (json)

Hi,

I’ve created a Powershell script which generates a password for me
Set-OctopusVariable -name “#{GeneratedPassword}” -value $randomGeneratedPassword
which i can then use once this step is finished:
$password = $OctopusParameters[“Octopus.Action[PasswordGenerator].Output.GeneratedPassword”]
Write-Host "New password: " $password

Which also works perfectly in my config files with variable substitution:
ConnectionString=…Password=#{Octopus.Action[PasswordGenerator].Output.GeneratedPassword};…

However, the problem is when i want to use this in my step (which runs after above steps) where the Azure resources are created or updated with ARM template:

This doesn’t work, it’s not substituted:
“password”: { “value”: “#{Octopus.Action[PasswordGenerator].Output.GeneratedPassword}” }

[] in Json also gives a NewtonSoft exception.

How can I use output variables in a ARM json parameter template?

Thanks in advance,
Jorik

Hi Jorik,

Thanks for reaching out. You seem to have double # in your variable: ##{Octopus.Action[PasswordGenerator].Output.GeneratedPassword}. Can you try removing it and see it if works?

Thanks,
Dalmiro

Hi,

Sorry that was just a copy past exception.

This doesn’t work:
“password”: { “value”: “#{Octopus.Action[PasswordGenerator].Output.GeneratedPassword}” }

Hi Jorik,

Sorry for the delay.

That should be working. Could you follow the below steps and send us your deployment log?

1) Add these 2 variables to your project http://docs.octopusdeploy.com/display/OD/Debug+problems+with+Octopus+variables

2) Create a new release (so the new variables take effect) and deploy it. If possible skip as many steps as you can and only leave step we are troubleshooting in order to avoid the noise in the log.

3) Send us the raw log of that deployment http://docs.octopusdeploy.com/display/OD/Get+the+raw+output+from+a+task

Thanks,
Dalmiro

If you could also send the parameters.json file, that would be great.

Hi Dalmiro,

Turns out that the generated password contained (sometimes) a double quote. Apperently this doesn’t lead to a problem when substituting the variables, but the json template is validated. Hence the Newtonsoft exception.

I found the problem by using the debug parameters, so thanks for your help!

Regards,
Jorik

Glad to hear you solved it!

Cheers