Create an Azure automation runbook
Here we will create a runbook in the automation account that will retrieve data from Microsoft Graph using the REST API and export the data to the Azure storage account.
PowerShell Modules
A couple of PowerShell modules are needed. If you are using the latest PowerShell runtime environment (7.2 at the time of writing), these modules should already be present and there should be no reason to create your own runtime environment. If you are using your own runtime environment, make sure the following modules are present and up-to-date.
Az.Accounts
Az.Storage
Prepare the Runbook
Download the automation runbook script from here: https://github.com/SMSAgentSoftware/IntuneAssignmentsReport/blob/main/Export-MSIntuneAssignments.ps1
In the Variables section near the top of the script, set values for the following variables:
ResourceGroup. The name of the Resource group that hosts the Azure storage account.
StorageAccount. The name of the Storage account.
Container. The name of the container you created.
Create a Runbook
Click on the Runbooks pane and choose Create a runbook.
Choose Browse for file and select the runbook script you downloaded.
Select the latest runtime environment (eg 7.2 at time of writing).
Click Review + Create.
When ready, Publish the runbook.
Schedule the Runbook
Schedule the Runbook to execute at regular intervals to keep the data updated, every 3 hours for example.
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
Last updated