I am writing a simple az command to return the default version of AKS. I have tried several variation as below, but the result set returned is the opposite of what I am after. Is there something I am missing with regards to the JMESPath filter expression and boolean values in the JSON?
These two commands, I would have thought, should return only the 'default' version. Instead, they return all but the default.
az aks get-versions -l $region --query "orchestrators[?default==true].[orchestratorVersion,default]" -o table
and
az aks get-versions -l $region --query "orchestrators[?default==true].{Version:orchestratorVersion,IsDefault:default}" -o table
In the end I used !=null filter instead, but would like to know the answer.
The data without the filter
az aks get-versions -l $region --query "orchestrators[].{Version:orchestratorVersion,IsDefault:default}" -o json
is as follows:
[
{
"IsDefault": null,
"Version": "1.10.12"
},
{
"IsDefault": null,
"Version": "1.10.13"
},
{
"IsDefault": null,
"Version": "1.11.9"
},
{
"IsDefault": null,
"Version": "1.11.10"
},
{
"IsDefault": null,
"Version": "1.12.7"
},
{
"IsDefault": null,
"Version": "1.12.8"
},
{
"IsDefault": null,
"Version": "1.13.11"
},
{
"IsDefault": true,
"Version": "1.13.12"
},
{
"IsDefault": null,
"Version": "1.14.7"
},
{
"IsDefault": null,
"Version": "1.14.8"
},
{
"IsDefault": null,
"Version": "1.15.4"
},
{
"IsDefault": null,
"Version": "1.15.5"
}
]
This is a rule in the JEMSPATH, you can see the description here, it's the Raw type this document. And it shows below:
There is also a difference between PowerShell and Shell.
In PowerShell, you can just use the "``" in the command like this:
az aks get-versions -l $region --query "orchestrators[?default == ``true``].[orchestratorVersion,default]" -o table
But in Shell, you need to use the "`" and make change like this:
az aks get-versions -l $region --query 'orchestrators[?default == `true`].[orchestratorVersion,default]' -o table