Azure Logic Apps, coupled with Log Analytics, offers a simple, but powerful solution for automating the creation and storage of reports from Log Analytics queries and sending them to blob storage.
Why automate Log Analytics query reports?
Many reasons as to why you may want to automate reports from log analytics queries, storing the data in blob storage that can be referenced else where, maybe even potential archiving. More reasons to automate:
Can even run them in a schedule, knowing the reports are automated and stored.
The 4 step Logic App workflow Solution with managed identity
I create a simple 4 step Logic App Workflow solution:
- Setup a schedule recurrence, which will run the next 3 steps on a schedule
- Run the Log Analytics query
- Format the query output into a csv table
- Store the csv into blob storage

(Log analytics and storage account has been created already)
- Please note: the logic app has been configured with a system assigned managed identity with IAM roles configured:
Logic Apps Reader roleto Log AnalyticsStorage Blob Data Contributorto Storage Account

Workflow breakdown
1. Recurrence (Schedule the Logic App to run)
- Set to run at 00:00 every day

2. Run query and list results
- Referencing the Log Analytics workspace to which I want to run the query against (Notice the reference of system assigned managed identity)

3. Create CSV table
- Creating CSV table from the query output from previous step

4. Copy CSV table to blob storage
- Mapping to the relevant storage account (notice the system assigned managed identity reference)

Reviewing blob storage
Lets have a quick look at blob storage, you will see a new .csv that has been added by this Logic App:

By following these steps, you will have automated the process of running Log Analytics queries and saving the results to Blob Storage using Azure Logic Apps.