question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

az graph query -o table missing columns in output

See original GitHub issue

az feedback auto-generates most of the information requested below, as of CLI version 2.0.62

Describe the bug az graph query command using -o table option is missing columns from output that are included when using other output formats such as -o tsv.

To Reproduce

  • Write your query, e.g.: resources | project     id,     type  | summarize resourceCount=count() by type | order by type asc
  • Save your query to a file e.g. resource-summary.kql
  • Run your query using -o table, e.g.: az graph query -q "$(<resource-summary.kql)" --first 5000 -o table > resource-summary.kql.txt
  • Examine results, note that type column is missing.
  • Run your query again using -o tsv, e.g.: az graph query -q "$(<resource-summary.kql)" --first 5000 -o tsv > resource-summary.kql.txt
  • Examine results, note that type column data is included. Expected behavior

All columns in results should be included in -o table output.

resource-summary.kql.table.txt resource-summary.kql.tsv.txt Environment summary

  • OS: Ubuntu 18.04.4 LTS on WSL 1
  • Azure CLI Version: 2.8.0
  • Azure CLI Install method: curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
  • Azure CLI resource-graph extension version: 1.1.0

Additional context

See file attachments for actual output.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
fenwicktcommented, Jul 19, 2021

Hi ankitsrao,

Sorry for the delayed reply. The first part of your question about id and type columns are not printed in table format is actually by design of Azure CLI. Please find the docs and the workaround in the ‘note’ section. Looks like you’re already using another workaround of renaming type column to a different name within the graph query itsef: “project resource=type”.

Regarding your 2nd question of the newer az cli version, the output of az graph cmdlet is changed for the pagination purposes to return a ‘skip_token’, 'count; and ‘total_records’ properties along with the ‘data’. So output of --table format is actually showing the top level properies which are now not your custom data properties but the default ones that I just mentioned.

As a workaround please try using JMESPath extension. Here is an example of rewriting your query with the newest az cli version: az graph query -q " summarize count() by type | where type =='microsoft.compute/virtualmachines' | project resource=type, total=count_ | order by total desc" --query 'data[].{resource:resource, total:total}' -o table

To downgrade the resource-graph extension please try to remove it and add with the older version:

az extension remove --name resource-graph
az extension add --name resource-graph --version 1.1.0
1reaction
msftbot[bot]commented, Jul 4, 2020

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @demyanenko.

Read more comments on GitHub >

github_iconTop Results From Across the Web

List of sample Azure Resource Graph queries by table
List sample queries for Azure Resource-Graph. Tables include Resources, ResourceContainers, PolicyResources, and more.
Read more >
SQL: Missing columns after INSERT - Stack Overflow
Your attempt fails because, basically, you are running 2 insert statements while you want just one record being generated.
Read more >
Table and Column Statistics | 6.3.x - Cloudera Documentation
The Impala query planner can make use of statistics about entire tables and partitions. This information includes physical characteristics such ...
Read more >
SQL ORDER BY | Basic SQL - Mode Analytics
This SQL tutorial for data analysis includes code and examples of using SQL ... You'll notice that the results are now ordered alphabetically...
Read more >
Data Manipulation with pandas - Yulei's Sandbox
.values : A two-dimensional NumPy array of values. .columns : An index of ... Fill in missing values and sum values with pivot...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found