Introduction
In this article, you will learn, how to add SharePoint online credentials and create schedules on Azure Runbook.
This article is the second part of an articles series which helps in creating Azure Runbook to create schedules for SharePoint online.
In my previous article, I explained the prerequisites like creating an automation and importing SharePoint online assemblies references to the portal.
The components, given below, are explained in detail here-
- Adding SharePoint online Credentials.
- Creating Runbook with the necessary script.
- Testing the script.
Add credentials
Azure Runbook will run the code at the scheduled run time. For this, we require the credentials to be stored on Azure automation portal.
- From our automation component, click assets. Click credentials.
- Click "add a credential" button. Provide SharePoint online portal tenant admin credentials, which will be used to run the schedules on Azure Runbook. Click create. The credentials will be saved to the portal.
- The following snapshot shows the stored credentials.
Create Runbook
Runbook on Azure helps-
- Writing the necessary automation scripts.
- Run the scripts, based on the schedules.
- View the results of the schedules.
- From the automation component, click Runbook under resources. Runbook lists down all the default published Runbooks, available for the automation.
- Click "Add a runbook". Click Quick create.
- Create Runbook with the Runbook name and type. Since in this example, we are going to run PowerShell scripts for an automation, we will select Runbook and type as PowerShell. Click create.
- Once created, the portal will show the screen, given below, with the script editors to add SharePoint script commands.
- The imported SharePoint online cmdlets can be seen under cmdlets section of Runbook. The snapshot, given below, shows the same-
- In Runbook code editor, write the necessary PowerShell script. In my example, I have written the code snippet to retrieve the available sites.
- To test the code snippet, save the code by clicking "save" and click "test pane" button available over the code editor. The test pane will open along with the console.
- From the test pane, click Start and wait for Runbook to complete the operations.
Summary
From this article, you have learned how to add SharePoint online credentials for an automation. Create Runbook and add the necessary script. Also, you have seen testing the written script.
In my next article, you will learn, how to run the scripts on the schedule time.