我们可以从给定的 azure cli 命令中获取单变量数组中的用户名和密码吗

问题描述 投票:0回答:1

这是我之前的问题的连续性或要求。

我们不能运行以下命令将用户名和密码存储在同一个数组变量中并获取,而不是运行一次用户名和密码命令。

$userNames=az webapp deployment list-publishing-profiles --name newjan --resource-group xxxx --query '[].userName' -o tsv
$userNames
$Passwords=az webapp deployment list-publishing-profiles --name newjan --resource-group xxxx --query '[].userPWD' -o tsv
$Passwords 

此代码片段由用户提供 Jahnavi

要求

我需要相同的命令将用户名和密码存储在同一个变量数组中,但当我尝试时遇到以下错误:

 $userCreds=az webapp deployment list-publishing-profiles --name newjan --resource-group xxxx --query '[].userName, [].userPWD' -o tsv
ERROR: argument --query: invalid jmespath_type value: '[].userName, [].userPWD'
To learn more about --query, please visit: 'https://docs.microsoft.com/cli/azure/query-azure-cli'
$userCreds=az webapp deployment list-publishing-profiles --name newjan --resource-group xxxx --query '[].userName', '[].userPWD' -o tsv
ERROR: argument --query: invalid jmespath_type value: "'[].userName',"
To learn more about --query, please visit: 'https://docs.microsoft.com/cli/azure/query-azure-cli'
azure azure-web-app-service azure-powershell azure-cli azure-appservice
1个回答
0
投票

除了我所做的SO之外,还可以使用命令

az webapp deployment list-publishing-profiles
一次性尝试完成,如下所示。

$Profile=az webapp deployment list-publishing-profiles --name <webapp> --resource-group xxxx --query '[].{UserName: userName, Password: userPWD}' -o tsv
$Profile

输出:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.