Username or Email Address
Automating every single task is one of the biggest challenges for every SysAdmin. Either you work on-premise or with Azure, you must automate most of your day-to-day task in order to save your time. In this article, I would like to introduce Azure Automation which is a software as a service (SaaS) application and a wonderful tool in order to automate repeated tasks. Nowadays, every SysAdmin should try to keep its IT infrastructure up and running.
If you have experience with automation workflow software like System Center Orchestrator or Service Management Automation (SMA), then you will be happy because Azure Automation is very similar. Azure Automation uses Runbooks. A runbook is a set of tasks that perform one or many actions automatically. For example, you can create a runbook that will:
Azure Runbooks are based on Windows PowerShell so you can use them to perform all your tasks by importing PowerShell modules, or calling another Runbook. If you don’t have PowerShell skills, you can use a graphical editor which lets you create graphical runbook. I will describe both options in this article.
Depending if you work on-premise or not, you will use one of these following automation software:
SMA is part of Microsoft Azure Pack and will be used locally for your private cloud. SMA uses PowerShell and PowerShell Workflow but does not support graphical runbooks.
Orchestrator is focused on on-premises resources. SCO has a graphical interface in order to create your Runbooks. You don’t need scripting skills because SCO uses activities from “Integration Packs” which are packages built specifically for Orchestrator.
Finally, Azure Automation is what you need if you work with Azure. Let’s see how it works.
Runbooks in Azure Automation cannot access resources in your on-premise environment. If you want to use Azure Automation to run specific action in your on-premises environment, then the Hybrid Runbook Worker (HRW) feature is what you need to implement. Azure Automation allows you to run Runbooks directly on the computer hosting the HRW role but Runbooks are stored and managed in Azure Automation.
Note that you can use DSC Configuration to manage your Azure Virtual Machines and on-premise machines. The only pre-requisite is to create an Outbound Firewall rule from your on-premise machine to Azure DSC Pull Server, communicating over TCP port 443.
Below is the Automation Architecture from Microsoft Website:
To get started using Azure Automation, you must create your first Automation account. What is an Azure Automation Account? An Automation account is separate from the account you use to sign in to the Azure portal. Azure Automation allows you to automate tasks against resources in Azure. So your Runbook must be able to perform specific actions, and it will use this Azure Automation Account which must have permissions to securely access the resources. Let’s see how to create the Azure Automation Account.
Go to the Azure portal, select “Automation Accounts”:
Click “Create Automation Accounts”
Now, fill out the following fields:
And click “Create” to add your Automation Account:
Now, I can create my first Runbook but I have to choose which type of Runbook I want to create. Azure Automation supports many types of Runbooks:
Let’s see how it works. Go to “Runbooks”, click “Add Runbook”, then either create a new Runbook or import an existing Runbook. Here I create a new Runbook based on Windows PowerShell.
Once the Runbook is created, click “Edit” in order to modify the Runbook which is actually empty.
In this Runbook, I just want to list all my Azure Virtual Machines. You can create your script from your ISE and copy/paste your code into the Runbook.
Notice the library on the left panel. This library can be used to add cmdlets, runbooks, and assets directly to your runbook. It can be very useful if you don’t remember the name of some cmdlets or just to include another Runbook. You also can add credentials from “Assets” tab. Click “…” and “Add to canvas”:
Once your runbook is ready, you can go to the test pane in order to check if it works or not. So click “Test pane”:
Now, you can test the runbook by clicking the “Start” button. The job status starts as Queued indicating that it is waiting for a runbook worker in the cloud to come available. It will then move to Running and Completed status.
The runbook is actually in a draft mode. We must publish it before we can use it in production. After publishing your runbook, you can schedule it or export it.
If you don’t have scripting skills, note that you can import several Runbooks created by the community. You also can import graphical Runbooks. The Azure Automation Runbook Gallery pulls Runbook content from the PowerShell Gallery in addition to Script Center. So to import an existing Runbook, you can click “Browse Gallery”:
When you import a Runbook, an entry will be added to your Runbooks repository:
All the previous steps can be performed with Windows PowerShell. For example, I can get all the Runbooks with the Get-AzureRmAutomationRunbook cmdlet:
Of course, I can create a Runbook using the New-AzureRMAutomationRunbook cmdlet:
Finally, if I want to publish a Runbook, I must use the Publish-AzureRmAutomationRunbook cmdlet to publish a Runbook with Windows PowerShell. The following commands show how to publish a Runbook:
First, you must create a Graphical Runbook. Once the Runbook is created, edit the runbook and Azure Automation will help you to build your first graphical runbook. Graphical Runbooks are different than Orchestrator Runbooks because SCO uses activities instead of PowerShell. Here, we must select an item from the library in the left pane and insert it to build the Runbook.
Once your Runbook is built with all the steps, we must configure properties into the right panel. Select an item, configure properties from the right panel.
When it’s done, simply click “Start” and Azure Automation will run all the steps inside the Runbook.
Thanks to Azure Automation, you can create PowerShell Runbooks or Graphical Runbooks in order to easily automate your day-to-day tasks. You can now start building any type of Runbook which can perform any action you need.
Azure is not free, so if you need more information about pricing, you can read this article: https://azure.microsoft.com/en-us/pricing/details/automation/
Thanks for reading!
Sample rating item
Microsoft, Services by Nicolas Prigent
You must be logged in to post a comment.