Intune Backup to Storage Account Pt.2 – The Automation Account

This post is about creating an Intune backup to a storage account Pt.2. You could use this to create a daily backup or even more frequent.

The clarify the above. I created a script that creates a backup from your Intune environment and uploads it to a storage account.

This part is about running the script in an Azure Automation Account. This enables the option to schedule your Intune Backup! Let’s go!

Other parts:

Intune Backup to Storage Account Pt.1 – The Script

Intune Backup to Storage Account Pt.3 – The Notification

Prerequisites

Complete the previous part in this series:

Intune Backup to Storage Account Pt.1

After that, you are ready to start this blog!

Creating the Automation Account

Firstly, log on to Microsoft Azure.

After that, search for Automation Account:

Intune Backup to Storage Account Pt.2 - Automation Account

Click on create:

Intune Backup to Storage Account Pt.2 - Automation Account create
Intune Backup to Storage Account Pt.2 - Automation Account parameters
Intune Backup to Storage Account Pt.2 - Automation Account overview

Your automation account is created!

Preparing the Automation Account

Go to the just created Automation Account. We need to add to some modules to the account. The modules give us the option the run the backup and the upload inside the storage account.

Go the modules option of the storage account:

Intune Backup to Storage Account Pt.2 - Importing Modules

The Az module is already present in the automation account. You see these modules already available in the account.

For example:

Intune Backup to Storage Account Pt.2 - Available Modules

Click on “Add a module”:

Intune Backup to Storage Account Pt.2 - adding modules

Select browse from gallery and click on “Click here to browse from gallery”:

Intune Backup to Storage Account Pt.2 - click for gallery

Search for “Intunebackup” and select the appropriate module:

After that, click on select:

Select the runtime version and click on import:

Furthermore, do the same for the “Microsoft.Graph.Intune” module.

Adding the script in a runbook

Firstly, go to the automation account and select “Runbooks”:

Intune Backup to Storage Account Pt.2 - add runbook

After that, click on create a runbook:

Next, name the runbook, select the type and runtime version:

Intune Backup to Storage Account Pt.2 - select parameters

After that, you need to copy the script from my github repository and paste it in the runbook:

Intune Backup to Storage Account Pt.2 - adding script

Furthermore, you need to edit the parameters:

In addition, this are the same variables as in part 1!

TenantID: Your tenantname
ClientID: The App ID from the Service Principal
StorageAccountName: The name of your storageaccount
RGName: ResourceGroupName for the StorageAccount
Container: ContainerName within the StorageAccount

Lastly, we need to add the secret as an encrypted variable. Go to variables:

Intune Backup to Storage Account Pt.2 - add variables

After that, click on “Add a variable”:

Enter the parameters:

Intune Backup to Storage Account Pt.2 - encrypted variables

This is what it should look like:

Running the Automation Account

And finally! We can run the Intune Backup to a Storage Account. Click on start:

Intune Backup to Storage Account Pt.2 - starting the automation account

By default, all the parameters are filled with the values that we entered earlier:

Click on “OK” to start the runbook.

After that, the backup starts:

Lastly, the backup is uploaded to your storage account:

This is the result (the same as in part 1)

Scheduling the Automation Account/Runbook

Go back to the automation account and click on schedules:

Click on “Add a schedule”:

Enter the variables for the schedule:

And that creates the daily Intune Backup!

That concludes the Intune Backup to Storage Account Pt.2

2 thoughts on “Intune Backup to Storage Account Pt.2 – The Automation Account”

Leave a Comment