[英]Azure Cli PowerShell - how to pass list query results (array) as inline Parameters?
In Azure Cli with Powershell. What I'm trying to do is list out all the existing KV secret names and then pass the array in as an inline parameter for ' az deployment group create ' command.在带有 Powershell 的 Azure CLI 中。我要做的是列出所有现有的 KV 机密名称,然后将数组作为内联参数传递给“ az deployment group create ”命令。
However, seems like the command doesn't like the format of JSON array so I got this error: ERROR: Failed to parse string as JSON但是,似乎该命令不喜欢 JSON 数组的格式,所以我收到此错误:错误:无法将字符串解析为 JSON
Upon checking docus, seems like it want something like "['value1','value2']" but my query result is ["t1","t2"] , so it will throw the error out.在检查文档时,它似乎想要类似"['value1','value2']" 的东西,但我的查询结果是["t1","t2"] ,所以它会抛出错误。
This surprised me as the query result are not supported natively by Azure CLI, wondering how can I convert my query results to the right format?这让我感到惊讶,因为 Azure CLI 本身不支持查询结果,想知道如何将查询结果转换为正确的格式?
$formattedOutput = @() foreach($line in $secretNamesArray) { $formattedOutput += "'"+$line+"'" } $existingSecretNames = "[" + ($formattedOutput -join ",") + "]"
Figured out, have to transform it.... what a wonderful job MS...弄清楚了,必须对其进行改造....多么出色的MS ......
also remember to wrap the results with double quote as well like:还记得用双引号将结果括起来,比如:
--parameters existingSecretNames="$existingSecretNames"
So it will pass something in like "['t1', 't2', 't3']"所以它会传递类似“['t1','t2','t3']”的东西
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.