
close
close
The Microsoft Azure Automation service has just hit general availability and allows administrators to automate tasks using runbooks. Based on PowerShell Workflows, runbooks differ from standard scripts in that they’re for automation of repeatable and frequently run tasks that are executed in parallel across multiple machines. Runbooks can be stopped, restarted, and even survive server reboots. Don’t worry if you don’t have any PowerShell experience. There are plenty of sample runbooks in the Azure management portal to get you started.
The Azure public cloud uses the same automation infrastructure as System Center 2012 R2 Orchestrator and Windows Azure Pack, allowing the creation, monitoring and provisioning of resources. There are two pricing tiers: free and standard. Find out more information on pricing on the Azure website.
advertisment
The two key differentiating factors between using Azure Automation and the PowerShell module for Azure from an on premise workstation to automate tasks in the cloud are high availability and global assets. The Service Management Automation (SMA) engine is always available and is subject to a service level agreement. Global assets are variables defined in Azure Automation that can be shared amongst all your runbooks. For example, instead of defining variables in individual runbooks, you refer to global assets, which can be modified centrally if something changes in your Azure environment.
Let’s get started with using Microsoft Azure Automation by diving into the steps you’ll need to follow to setup and configure the service, starting with setting up automation in your Microsoft Azure account.
The first step is to set up an automation account for your subscription. Log in to the Azure management portal and follow the steps below.
Setting up an automation account in Azure. (Image Credit: Russell Smith)
The Azure module should already be imported and ready for use, but before we can use runbooks, we need to add a credential asset to allow the automation engine to authorize to the Azure subscription. The easiest way to achieve this is to use an Active Directory (AD) organization ID (OrgID). This can be any OrgID from an AD associated with your Azure subscription. Azure Automation cannot use Microsoft accounts for authorization.
advertisment
I have an Office 365 AD added to my Azure subscription, but you could also use Azure’s own basic or premium Active Directory services. If you don’t already have Active Directory in your Azure subscription, add an existing directory or create a new one using NEW > APP SERVICES > ACTIVE DIRECTORY > DIRECTORY in the management portal.
Creating a new Active Directory user. (Image Credit: Russell Smith)
Obtaining a temporary password. (Image Credit: Russell Smith)
The new user account should now appear in the main portal window. Make a note of the username as we’ll need it later. Before doing that, we’ll make the new user a co-administrator of the Azure subscription.
Creating a new Azure subscription co-administrator. (Image Credit: Russell Smith)
The new Azure administrator should appear in the main portal window after a few seconds. Now we need to log in as the new user in order to assign a permanent password.
Changing the new user’s password. (Image Credit: Russell Smith)
At this point you should be successfully logged in to the Azure management portal. You can choose to continue working under this account, or log out and sign in using your usual Azure administrator account.
advertisment
Before we can use the new account in Azure Automation, we need to set it up as a global asset to be referenced from our runbooks.
Creating a new Azure Automation credential asset. (Image Credit: Russell Smith)
Adding the AD user’s credentials to the new automation asset. (Image Credit: Russell Smith)
In a few seconds, you should see the new credential asset appear in the main portal window.
Now we have authentication configured, we can add a runbook. In this example, we’ll add a pre-created runbook from the Azure gallery.
Adding a new runbook from the gallery. (Image Credit: Russell Smith)
Setting the runbook details. (Image Credit: Russell Smith)
After a few seconds, the new runbook will be imported. Before it can be run, we need to make a couple of simple changes to the workflow. Make sure you are in the automation account section of the Azure portal before continuing.
Modifying variables in the runbook to match your Azure environment. (Image Credit: Russell Smith)
The locations for the code modifications are indicated in the figure above. Additionally, the automation name credential should be as specified when creating the credential asset, it doesn’t necessarily have to be in the [email protected] format and was shown highlighted in a previous image.
Saving and testing the runbook. (Image Credit: Russell Smith)
In the output pane, you should see the script run with no errors. If any VMs were running, you should also see that they have now stopped.
Once you have tested the runbook and made sure it works correctly, publish it and schedule it to run.
Setting the runbook to execute on a schedule. (Image Credit: Russell Smith)
The new schedule should appear in the console window, and your runbook executed according to the schedule.
More from Russell Smith
advertisment
Petri Newsletters
Whether it’s Security or Cloud Computing, we have the know-how for you. Sign up for our newsletters here.
advertisment
More in Microsoft Azure
Microsoft's Azure AD Conditional Access Service Can Now Require Reauthentication
May 13, 2022 | Rabia Noureen
Microsoft Addresses Cross-Tenant Database Vulnerability in Azure PostgreSQL
Apr 29, 2022 | Rabia Noureen
Microsoft Simplifies IT Monitoring with New Azure Managed Grafana Service
Apr 19, 2022 | Rabia Noureen
System Center 2022 is Now Available with New Datacenter Management Capabilities
Apr 4, 2022 | Rabia Noureen
Most popular on petri
Log in to save content to your profile.
Article saved!
Access saved content from your profile page. View Saved
Join The Conversation
Create a free account today to participate in forum conversations, comment on posts and more.
Copyright ©2019 BWW Media Group