# Create an Azure automation runbook

{% hint style="info" %}
This process uses the [Runtime Environment experience](https://learn.microsoft.com/en-us/azure/automation/runtime-environment-overview).
{% endhint %}

{% hint style="info" %}
The **Az.Accounts** and **Az.Storage** modules are required to execute this runbook. If you wish to use a **System-generated Runtime environment**, you should be fine as the Az modules are already included. If you use your own runtime environment, make sure the Az modules are included.
{% endhint %}

{% hint style="warning" %}
It is highly recommend to use the latest PowerShell Core runtime version to execute the runbook (7.2 at the time of writing)
{% endhint %}

## Download the Runbook script

Download the [Export-MSGraphPatchMyPCData.ps1](https://github.com/SMSAgentSoftware/PatchMyPCReport/blob/main/Export-MSGraphPatchMyPCData.ps1) runbook from my GitHub repo.

## Configure the script

In the runbook script, set the **first four** variables in the **Variables** script region at the top.

**$ReportType**. Only the '**Overview**' report is now available.

**$ResourceGroup**. Enter the name of the Azure resource group containing your Azure storage account.

**$StorageAccount**. Enter the name of the Azure storage account.

**$Container**. Enter the name of the Container in your storage account where you'll be exporting the data.

## Create the Runbook

* Click on the **Runbooks** pane and choose **Create a runbook**
* Choose **Browse for file** and locate the runbook script file
* Select a **Runtime Environment**
* Enter a **Description** if desired, and click **Review + Create**, then **Create**
* In the **Edit PowerShell Runbook** windo&#x77;**, 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/-Mdb-dKf7HOTU8cF6bcx)


---

# 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/patch-my-pc-report/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.
