In a few of my previous articles (listed below) we have learned how to automate the process of provisioning resources using Azure Resource Manager (ARM) template.

ARM templates are helpful for automating the process of provisioning and deploying the same to Azure. However, if you want to repeat some regular operational or maintenance tasks, the ARM template might help us a lot. For example: If you would like to stop a VM (or a set of VMs) after a task is complete, or you would like to scale vertically or horizontally the computer resources for a certain period of time, ARM might not help us.

This is where Azure Automation comes into the picture. Below is the definition from the Official documentation

Microsoft Azure Automation provides a way for users to automate the manual, long-running, error-prone, and frequently repeated tasks that are commonly performed in a cloud and enterprise environment. It saves time and increases the reliability of regular administrative tasks and even schedules them to be automatically performed at regular intervals.

Before we dive into how to automate regular administrative tasks, let’s look at a few of the concepts around Azure Automation.

Runbook

Basically, it’s like a container of Windows PowerShell Scripts which we can use to automate the tasks. These PowerShell scripts have access to all the cloud resources associated with the subscription.

Assets

Assets are entities that could be associated with multiple runbooks. Below are the assets that are currently supported.

Hybrid Worker

As explained above, Runbooks have access only to the Cloud Resources but not to the resources located on-premises. This is where Hybrid Workers are helpful. These workers allow us to run the runbooks on our local data center for managing the resources and performing the administrative tasks. In order to make this work, you need to install Hybrid Worker. For more details.

In order to automate the administrative tasks, we first need to have an Automation Account. Let’s go ahead and create one as shown in the below screen captures.

Account

Click on the “Automation Accounts” link on the left hand menu as shown in the above screen capture. If you don’t see the link, click on “Browse” and search for “Automation Accounts" as shown below.

Account

Clicking on the “Automation Accounts” will take you to the “Automation Accounts” blade as shown below.

ADD

Currently, I don’t have any accounts. Let’s go ahead and create one by clicking on the “Add” of the above screen capture.

ADD

Please provide the name of the account and select a Resource Group and the location. It's suggested to select the same location where your resources are located to avoid the latencies.

Select “YES” in the “Create Azure Run As account” toggle button. Basically, this is used to impersonate a user for running the Automation Services. Now, click on “Create” button to create the Automation account.

Account

The above screen capture displays the new account that we just created. Hope you enjoyed the basics of the Automation account.