首页 > 解决方案 > az devops powershell 传递空格分隔的值

问题描述

AZ devops 命令 az pipelines variable-group create将 --variables 定义为“格式为键=值空格分隔对的变量”

我需要创建一个包含 20 多个键 = 值对的变量组。我发现很难将其作为一个变量。

此命令行有效

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

我正在尝试做这样的事情:

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

我查看了这篇文章,该文章显示了希望,但推荐的答案不起作用 空格分隔值;如何提供包含空格的值

任何想法如何实现?

标签: azure-powershellazure-cli2

解决方案


您可以尝试以下方法。

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

我没有 AZ DevOps,但在 PowerShell ISE 上使用 Azure CLI 验证了类似的场景。如果您在 Bash 上运行 Az CLI,则可以按照链接的答案进行操作。

在此处输入图像描述


推荐阅读