Hello @Anonymous ,
This is somewhat tricky , when you are using the --query the JSON key names which you are trying to query is Case Sensitive.
This will be the exact query:
az account list-locations --query "[].{name:name,region:regionalDisplayName}" --output table
Your query:
az account list-locations --output table --query "[].{name: Name, region: RegionalDisplayName}" {See the display name it should be regionalDisplayName instead of RegionalDisplayName , see the Name it should be name}
Basically , if you see the --query parameters
name:name, (headername:exact name of the JSON output of az account list-locations i.e. name)
region:regionalDisplayName (headername:exact name of the JSON output of az account list-locations i.e. regionalDisplayName)
To validate the exact json names :
- Run the query az account list-locations
- Examine the output (Check the JSON Array values)
Example JSON output:
{
"displayName": "Brazil Southeast",
"id": "/subscriptions/subid/locations/brazilsoutheast",
"metadata": {
"geographyGroup": "South America",
"latitude": "-22.90278",
"longitude": "-43.2075",
"pairedRegion": [
{
"id": "/subscriptions/subid/locations/brazilsouth",
"name": "brazilsouth",
"subscriptionId": null
}
],
"physicalLocation": "Rio",
"regionCategory": "Other",
"regionType": "Physical"
},
"name": "brazilsoutheast",
"regionalDisplayName": "(South America) Brazil Southeast",
"subscriptionId": null
}
So , to summarize when you are trying query JSON output, the Key names are casesensitive.
If the above help you out in understanding , kindly make sure to "Upvote and Accept the answer". It will help all thecommunity out there.