1

I've entered into a bit of syntax nightmare, everything I have tried so far just will not work.

Its a single line...which works absolutely fine until I work in some Release Pipeline variables with the $(env:name-of-var) stuff...

$primarykey = (Get-AzRelayKey -ResourceGroupName $($env:az-resourcegroupname) -Namespace $($env:az-relaynamespace) -HybridConnection $($env:AF.actionResultRelayConnectionName) -Name $($env:AF.actionResultFalloverRelayKeyName) | Select-Object -ExpandProperty PrimaryKey)

Any ideas greatly received. Thanks in advance.

1
  • Hi, thanks for the reply. The variables exist in the Release Pipelines' variable set. Error is around the - character in the var name... + ... Get-AzRelayKey -ResourceGroupName $($env:az-resourcegroupname) -Names ... + ~~~~~~~~~~~~~~~~~~ Unexpected token '-resourcegroupname' in expression or statement. Commented Jul 17, 2019 at 15:13

1 Answer 1

3

Because you have - in the variable name you got an error.

You can do it in this way (instaed of $($env:az-...)):

${env:az-resourcegroupname}
${env:az-relaynamespace}
Sign up to request clarification or add additional context in comments.

4 Comments

I've tried that but while it passes syntax, the var can't be resolved and reports as empty. Seems like chars like - or . can't be used here??
I've tried the following experiment .... Created a var in the pipeline called "basicvar" with a value of "nospecialchars" and I put in my Azure Powershell script the following 2 lines...line (1) is write-host $($env:basicvar) and line 2 is write-host ${$env:basicvar} - the first one resolves the value "nospecialchars" the second line reports as empty
OK - I've re-read what you put @Shayki so thank you, for the vars with a - you put into {} and REMOVE the extra $ - that is what I am missing. My next problem is what to do with vars with a . in them. Now my var with the . doesn't resolve. I've tried the following...write-host $($env:AF.actionResultRelayConnectionName) and write-host ${env:AF.actionResultRelayConnectionName} - both statements come out as blank!
Thanks for your continued help. Yes I think that is for the best, I gave up after a while of testing these, seems that Release Pipelines just don't work with periods in blog.danskingdom.com/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.