Search code examples
azure-powershellazure-cli2

az devops powershell passing space delimited values


The AZ devops command az pipelines variable-group create takes --variables defined as "Variables in format key=value space separated pairs"

I need to create a variable group with 20+ key=value pairs. I'm finding it hard to do so as a variable.

This command line works

 az pipelines variable-group create --name myname --variables “owner=Firstname Lastname” “application=cool-name” 

I'm trying to do something like this:

$tags ={owner='Firstname Lastname' application='cool-name'} 
az pipelines variable-group create --name owgroup --variables $tags 

I looked at this article that showed promise but the recommended answer(s) doesn't work Space separated values; how to provide a value containing a space

Any ideas how this can be accomplished?


Solution

  • You could try the following.

    $tags=(“owner=Firstname Lastname”, “application=cool-name”)
    az pipelines variable-group create --name owgroup --variables $tags
    

    I have not AZ DevOps but validate a similar scenario with Azure CLI on PowerShell ISE. If you are running Az CLI on Bash, you could follow your linked answer.

    enter image description here