# Automate Data Export to Azure Storage Account

Below is an example PowerShell runbook that can be used in an Azure automation account to export data from Microsoft Graph to an Azure Storage account as a CSV file. It exports Windows devices with a selection of fields.

The following is assumed:

* You have enabled a **system managed identity** for the Azure automation account and granted it the appropriate **API permissions to Microsoft Graph.**
* You have assigned the managed identity a **role with the appropriate permission** to upload and modify blobs in the **storage account**.

You need to provide the following as variables in the script:

* **$ResourceGroup** - the name of the resource group containing the storage account
* **$StorageAccount** - the name of the storage account
* **$Container** - the name of the container which will hold the exported file

{% embed url="<https://github.com/SMSAgentSoftware/MEM/blob/main/Intune%20reporting/Export-MSGraphToAzStorageAccount.ps1>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.smsagent.blog/microsoft-endpoint-manager-reporting/automating-data-exports-from-microsoft-graph/automate-data-export-to-azure-storage-account.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
