# 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)


---

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