exporting query output report to csv

Diptesh Kumar 101 Reputation points
2024-05-21T09:11:38.7066667+00:00

I have executed below query and it worked and i want to export report to csv, what parameters I should add?

'az graph query -q "Resources | where type =~ ''Microsoft.Compute/virtualMachines'' | project name, properties.storageProfile.osDisk.osType | top 5 by name desc"

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,409 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Prrudram-MSFT 22,936 Reputation points
    2024-05-23T09:37:02.09+00:00

    Hello @Diptesh Kumar

    Thank you for reaching out to the Microsoft Q&A platform.'

    Method 1:

    You can download CSV results from the Azure portal, browse to the Azure Resource Graph Explorer and run a query. On the toolbar, click Download as CSV.

    Note:

    CSV export result size limitation

    When using the comma-separated value (CSV) export functionality of Azure Resource Graph Explorer, the result set is limited to 55,000 records. This is a platform limit that cannot be overridden by filing an Azure support ticket.

    User's image

    Alternative methods using cmdlets:

    Method 1:
    If you are using Azure CLI(cloud shell) use the below command in PowerShell mode to run the graph query and export the results as csv

    Ex: Search-AzGraph -Query "Resources" -first 1000 | epcsv .\testgraph.csv -NoType

    Method 2:

    If you are interested to do it through a bash in azure CLI(cloudshell). Unfortunately we do not have cmdlet/function to convert tsv to csv.
    If you are interested to convert it to csv Here’s how you can do it in Azure CLI: https://stackoverflow.com/a/22421445

    If I have answered your query, please click "Accept as answer" as a token of appreciation