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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` 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>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
