Some variables not populating correctly

Hi,
Not sure if this one is a bug or I’m misusing the tool in some way.
I’ve created a step in my deployment which starts a VM, in this step I’ve defined a powershell script which will start the VM based on some tenant variables;

‘Start-AzureRmVM -ResourceGroupName “${ClientIdentifier}-${EnvironmentIdentifier}-RG” -Name “${ClientIdentifier}-${EnvironmentIdentifier}-VM”"’

The ClientIdentifier here is in all but one case the same as another tenant variable, the one exception is where we have ‘UK’ appended:

This fails to start the VM as the resource group is called ‘Batman-Test-RG’ and not ‘BatmanUK-Test-RG’.
The simple solution would be for me to use ${Tenant.Alias} in the powershell script, however whenever I use this it pulls through as blank…

Any ideas as to why the ${Tenant.Alias} variable is pulling through blank?

Thanks,
Archie

Hi Archie,

Thank you for contacting Octopus Support.

I hope you don’t mind, I have a few questions/request:

I look forward to hearing back from you and helping you get this resolved.

Regards,
Donny

Hi Donny,

Thanks for the quick reponse.
Octopus Server version: v2019.9.10 LTS
ServerTasks-246162.log.txt (1018.5 KB)
deploymentprocess-Projects-181.json (104.3 KB)

Thanks,

Archie

Hi Archie,

Thank you for getting back to me.

It looks like the variable will need to use OctopusParameters[] rather than the calling it via $variable. Here is an example I tested below:

write-host "Start-AzureRmVM -ResourceGroupName "${ClientIdentifier}-${EnvironmentIdentifier}-RG" -Name "${ClientIdentifier}-${EnvironmentIdentifier}-Invest-VM""

Start-Sleep -s 1

$TA = $OctopusParameters["Tenant.Alias"]
$TA = $TA.ToLower()

Write-Output "Successfully turned on ${ClientIdentifier}-${EnvironmentIdentifier}-Invest-VM; tenant is ${Alias} or $TA"

To account for this and to utilize “ToLower”, I set the OctopusParameter to a variable.

Let me know if that change works in this case for you.

Regards,
Donny

Hi Donny,

That’s worked!

Thanks so much for the help :slight_smile:

Archie

1 Like

Hi Archie,

Thank you for getting back to me. I’m glad to hear it worked for you!

If you need anything else, don’t hesitate to reach out.

Regards,
Donny