0
votes

I have a PowerShell script where I have multiple output variables generated with the following syntax :

Write-Host ("##vso[task.setvariable variable=appObjectId;issecret=false]"+$appObjectId)

In the PowerShell task in Azure DevOPS, I have set the Output variables as follow: enter image description here

Then, I use my output variables in an Azure Resource Group deployment as follow: enter image description here

Unfortunately, when I look into the deployment details in Azure, I can see that the parameters of my ARM are not filled out with the value of the output parameters but with the name of it: enter image description here

Important information: the ARM deployment task is done inside a task group. My PowerShell script is in the pipeline, just before the call to the Task Group. I tried to put the script inside the Task Group but I have the exact same issue.

3

3 Answers

0
votes

I found the root cause: I need to enclose the parameter "$(myParam)" in the tasks where I need to use it. Otherwise, it is not computed.

-1
votes

I think you might have gotten the format wrong for defining the output variable from your Powershell script, this should work -

Write-Host "##vso[task.setvariable variable=appObjectId;isOutput=true]$appObjectId"

-1
votes

Update

Also add is isoutput=true, the defaults to false.


Cause you are not set the variable to appObjectId correctly. There is not AADApplication.appClientid. Then Azure DevOps treat this to string. That's why the parameters of my ARM are not filled out with the value of the output parameters but with the name of it.

No need to use () to include the follow set variable command.

SetVariable: Initialize or modify the value of a variable

##vso[task.setvariable]value

You should use the following syntax :

Write-Host "##vso[task.setvariable variable=appClientID;issecret=false;isoutput=true]value"

More details please refer our official doc here.