> For the complete documentation index, see [llms.txt](https://docs.smsagent.blog/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.smsagent.blog/microsoft-endpoint-manager-reporting/automating-data-exports-from-microsoft-graph/automate-data-export-to-azure-storage-account.md).

# 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>" %}
