How to download as csv Azure Resource graph query results to a storage account using a Logic App

Tsholofelo Mautla 26 Reputation points
2022-12-13T19:16:37.79+00:00

Hi
I want to use a logic app to run a query within Azure Resource Graph and then download the query results to Azure storage account from within the Logic App step.

I am able to connect the Logic App to the Resource Graph and run the query.

I am now stuck on getting the query results to an Azure storage account.

I appreciate all guidance.

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. MayankBargali-MSFT 70,986 Reputation points Moderator
    2022-12-14T06:18:38.697+00:00

    @Tsholofelo Mautla Thanks for reaching out. As you already have the array output from your query result action. You can leverage the create CSV table action to convert your output to CSV format. Now you can leverage the Create Blob action and pass your CSV table action out as the blob content. For testing I have defined the variable and pass the array output of resource graph documented here

    Workflow :
    your previous workflow action --> Create CSV table --> Create Blob

    270336-image.png

    Feel free to get back to me if you need any assistance.

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

    0 comments No comments

  2. Tsholofelo Mautla 26 Reputation points
    2022-12-16T14:06:13.66+00:00

    Hi @MayankBargali-MSFT
    Thanks for getting back to me.
    I am currently getting an error on my script in the logic app.
    This is what I am trying to do.

    • use a logic app to connect to Azure Security center and get the "Blocked accounts with owner permissions on Azure resources should be removed" identity and access recommendation.
    • run the Resource graph query available in Security center (See attachments).
    • export the results as csv and then save them to an Azure storage account
    • Then get the csv and run a script that will remove RBAC for the object identities listed in the CSV.
    • link to script below 271350-resource-graph-query.txt271414-image-2.png271433-image-1.png

    https://techcommunity.microsoft.com/t5/microsoft-defender-for-cloud/remove-deprecated-user-accounts-across-multiple-subscriptions/ba-p/2275836

    I am not sure if Logic App is the best tool for this or not or if it would be better to run everything in Powershell?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.