0

How to pass multiple values as a single parameter in AzureDevops Release Pipeline.

Example

I have a automation script that creates multiple storage accounts based on input. If the input is test1,test2,test3,test4,test5 it creates five storage acocunt in azure. This scripts works fine when I run from powershell on my local machine but its not working when i try same from "Release Pipeline" in azuredevops.

I have created a Powershell task in AzureDevops and Passing variable as "Inline" text

This is how I defined input in Variables group

Storageaccount : "test1","test2", "test3", "test4", "test5"

charles
  • 11
  • 1
  • 3

2 Answers2

0

You didn't attached your script here so I may only guessing. But probably your script expects some kind of array. And you can store an array in Azure DevOps variable. They are simple string. So what you can do is kind of (Assuming that Storageaccount : "test1,test2,test3,test4,test5"


$accounts= "$(Storageaccount)".Split(",")
invoke-here-your-script $accounts

In powershell task on Azure DevOps.

Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107
  • Yes my script takes the input as Array. I have tried above mentioned method in AzureDevops task but rather than creating Five different storage accounts it create one storage account with Five names appended. – charles Dec 14 '20 at 22:40
  • Please show the code. Can you edit your question and the code? – Krzysztof Madej Dec 14 '20 at 22:43
0

It seems fine to define the Storageaccount:"test1","test2", "test3", "test4", "test5". Check below:

1, Define variable Storageaccount in Variable group:

enter image description here

2, Use foreach in poweshell inline script to loop through the Storageaccount:

$accounts= $(Storageaccount)

foreach($account in $accounts){
   echo "----"
   echo "New-AzStorageAccount : $account"
    }

See below output:

enter image description here

Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43