I am trying to find all VMs with exactly 2 cores:
$ az vm list-sizes -o json --query "[?numberOfCores == 2]"
az vm list-sizes: error: argument --query: invalid query value: '[?numberOfCores == 2]'
As I suspected an error with the az
command, I installed jp directly, but it also gives an error:
$ az vm list-sizes -o json | jp "[?numberOfCores == 2]"
SyntaxError: Invalid token: tNumber
[?numberOfCores == 2]
In the jmespath specification it looks like I have to use the backtick `
character, but instead of an error it just gives no results:
$ az vm list-sizes -o json | jp '[?numberOfCores == `2`]'
[]
This is the (abbreviated) returned json I'm trying to filter:
$ az vm list-sizes -o json | head -n 20
[
{
"maxDataDiskCount": 4,
"memoryInMb": 123,
"name": "Standard_DS1",
"numberOfCores": 1,
"osDiskSizeInMb": 456,
"resourceDiskSizeInMb": 789
},
{
"maxDataDiskCount": 8,
"memoryInMb": 123,
"name": "Standard_DS2",
"numberOfCores": 2,
"osDiskSizeInMb": 456,
"resourceDiskSizeInMb": 789
}
]
(I obfuscated the sizes because I don't want to be sued by MS for sharing trade secrets or something)