Azure Automation using Runbooks – Part 1

Santosh Gaikwad

Connect on LinkedIn      Follow SCI Page

Write to
Santosh Gaikwad

Latest posts by Santosh Gaikwad (see all)

>> Azure

Problem Statement

Generally we have a requirement of running frequently repeated tasks that are commonly performed in a cloud environment. It consumes lot of time and also manual activities are not reliable.

Azure provides a way for users to automate the manual process using Azure Automation Runbooks. It saves time and increases the reliability and enables to schedule tasks to be automatically performed at regular intervals.

Azure Automation

Azure Automation is a software as a service (SaaS) application that provides a scalable and reliable, multi-tenant environment to automate processes with runbooks.

Runbooks that you run in Azure are executed on Automation sandboxes, which are hosted in Azure platform as a service (PaaS) virtual machines.

For example, you might have an existing manual process for truncating a SQL log file, if it’s approaching maximum size. This process includes multiple steps such as connecting to the server, connecting to the database, get the current size of log, check if threshold has exceeded and then truncate it and notify user. Manual and recurring process for this activity would be very time consuming and also less reliable, instead of manually performing each of these steps, you can create a runbook that would perform all of these tasks as a single process. You can start the runbook, provide the required information such as the SQL server name, database name, and recipient e-mail and also can schedule for recurring execution.


A Runbook is a set of tasks that perform some automated process in Azure Automation.

Runbooks in Azure Automation are based on Windows PowerShell or Windows PowerShell Workflow, so they can do anything that PowerShell can do.

It may be a simple process such as starting a virtual machine and creating a log entry, or you may have a complex runbook that combines other smaller runbooks to perform a complex process across multiple resources.

Runbooks can consume any custom cmdlets of PowerShell, and can access any cloud resources or external resources that can be accessed from the cloud.

Microsoft provides some sample runbooks in a runbook gallery, you can have a look at runbook gallery

Different methods to execute Runbook

Azure provides different ways to execute runbooks as follows.


Azure Portal

This simplest method which uses Azure login credentials to execute runbook from portal.  

Windows PowerShell
This method enables to execute runbook from command line with Windows PowerShell cmdlets.

We can create a powershell file to automate the execution process with multiple steps.  Unlike portal, authentication need to be done with certificate or OAuth.

Azure Automation API
This method is most complex in all for implementation.

It enables to execute runbook from any custom code that can make HTTP requests.  Like powershell, authentication need to be with certificate, or Oauth

This method enables to start runbook from single HTTP request. Authentication happens with security token in URL.

Respond to Azure Alert
This method starts a runbook in response to Azure alert. Need to configure webhook for runbook and link to alert.

This method is used to automatically start runbook on hourly, daily, weekly, or monthly schedule.

We can modify schedule through Azure portal, PowerShell cmdlets, or Azure API.

From Another Runbook
We can use runbook as an activity in another runbook. This is useful when we want to reuse some functionality across runbooks.


>> Azure

Check Articles From Categories      Health and Parenting      Inspiring Stories      Technology      Microsoft Azure      SharePoint O365

Leave a Reply

Your email address will not be published. Required fields are marked *