> 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/azure-automation-account/create-an-azure-automation-runbook.md).

# Create an Azure automation runbook

## Video guide

Here is a video guide which I created for the Patch My PC report which covers the steps outlined below.

{% embed url="<https://youtu.be/HswgdFVzDPw>" %}

## Import Modules

If you wish to export data to an Azure storage account, you will need a couple of PowerShell modules added to the automation account for the runbook to use.

* In the Azure portal in the automation account, go to the **Modules gallery** pane
* Search for and import the following modules:
  * **Az.Accounts**
  * **Az.Storage**

## Create a Runbook

* Click on the **Runbooks** pane and choose **Create a runbook**
* Enter a name for the runbook, select **PowerShell** for the runbook type and click **Create**
* Here you can enter your PowerShell code. To get started, check out the included examples for [exporting to an Azure storage account](/microsoft-endpoint-manager-reporting/automating-data-exports-from-microsoft-graph/automate-data-export-to-azure-storage-account.md) and [exporting to a Log analytics workspace](/microsoft-endpoint-manager-reporting/automating-data-exports-from-microsoft-graph/automate-data-export-to-azure-monitor-logs.md).
  * If you wish to test the runbook before publishing to make sure it works, use the **Test pane**
  * Alternatively, **Publish** the runbook, then click **Start** from the runbook menu. This option will give you the full output of the script.
* When ready, **Publish** the runbook

## Schedule the Runbook

Schedule the Runbook to execute at regular intervals to keep the data updated.

* In the Azure portal, in the automation account, open the Runbook you created
* Click **Link to schedule**
* In the **Schedule** section, select an existing schedule or create a new one

![](/files/-M_SHJw26sAMuYhaSEaI)
