这是我来自azure cli的输出,输出为await fixture.whenStable();
。
-o json
我需要打印唯一的ID,这样我才能运行命令:
[
{
"cloudName": "AzureCloud",
"id": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
"isDefault": true,
"name": "CSC Number One",
"state": "Enabled",
"tenantId": "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ",
"user": {
"name": "user1@gmail.com",
"type": "user"
}
},
{
"cloudName": "AzureCloud",
"id": "AAAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAA",
"isDefault": false,
"name": "CSC Number two",
"state": "Enabled",
"tenantId": "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY",
"user": {
"name": "user1@gmail.com",
"type": "user"
}
}
]
这将为我打印所有ID,即az account list --query [].id
和xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx
。
现在,我想仅在AAAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAA
处打印ID,这意味着结果应该是name = "CSC Number One"
。
答案 0 :(得分:0)
id
属性CSC Number One
@|[? @.name == `CSC Number One` ]|[*].id