One of the most popular automation tools is Azure Automation and this will be a series of posts covering the introduction to Azure Automation, creating automation runbooks, dealing with assets, testing and publishing runbooks.
Nowadays, automation is regarded as a significant skill to acquire when you’re in the IT service industry. Not just for DevOps, but even for ITOps and SysAdmins. Automation can be considered as a train that you either get on to or get left behind or worse, be run over by it.
Learning automation is one way to upgrade your skillset. To some degree, your worth would also increase, and you may be considered as one of the valuable members in your team or your company as a whole.
Azure Automation is one of the services available in Azure. It enables you to deploy and run PowerShell scripts without having to use a virtual or physical machine.
With Azure Automation, you can deploy your scripts serverless. There’s also no need to deal with having to set up Task Scheduler interval. This can also eliminate the risk of exposing credentials because can be saved as assets instead of saving them in plain text files.
There could be many reasons why Azure Automation can be used. These are some of the things you may want to consider.
At this day and age, there are fewer tasks that cannot be considered for automation. Some may seem like they cannot be automated. But sometimes, with a little creativity, there’s not much that you can’t automate.
In the end, through continued use and practice, you will be able to determine with much more confidence when and when not to use Azure Automation.
In this series, there will be demos and examples. You need to have the following to effectively follow along.
Throughout this series, I will be using my Visual Studio Enterprise subscription to show you the demos and examples working with Azure Automation.
I will also show the demos using the Azure Portal and PowerShell whenever possible. Using the portal may be convenient for some, but using PowerShell is highly recommended.
Before you can do anything with Azure Automation, you must be logged in to Azure first. There are two ways you can be logged in.
Note that the Azure Portal and the Azure Portal Desktop App are the same. They are both GUI-based, and the only difference is that the Azure Portal is accessed using a Web Browser, while the Azure Portal Desktop App accesses the Azure Portal using a dedicated app.
Using any browser of your choice, navigate to https://portal.azure.com. Then you will be asked for your login credentials. Enter your username then click Next.
Enter your username
Then you will be asked to enter your password, click Sign in.
Enter your password
And you will be taken to the Microsoft Azure homepage.
Microsoft Azure homepage
Note that before you can use PowerShell with Azure, you must make sure that the PowerShell Az module is installed. Otherwise, you will not be able to use the Azure commands in PowerShell.
Open a PowerShell session and log in to Azure using the command below.
Connect-AzAccount
Just like when logging in using the Azure Portal, you will be prompted for your username, then your password similar to the screenshots you see below.
Enter your username
Enter your password
Once login is successful, you will see a similar output as shown below in the PowerShell console.
Login to Azure is successful
There are five (5) Azure automation resources that you must be familiar with. Below are the short descriptions for each.
To use Azure, you pay a fee for subscription. This is to say that you do not own the resources, you are just being permitted to use them as part of your subscription.
Resource Group is used to logically group Azure resources like virtual machines, IP addresses, DNS Zones and so on. And these Resource Groups belong to or are created under a subscription.
This resource is specific to Azure Automation. It is located inside a resource group when created. In a way, it is similar to a resource group because it acts as a logical container but only specific to Azure Automation.
A runbook is simply a PowerShell script that runs in Azure. It is what’s in the center of your automation projects.
These are the items stored in the automation account that can be accessed and used by runbooks. These could be credentials, variables, and schedules, among others.
Remember that Automation Accounts are located inside resource groups, and resource groups below to specific subscriptions.
To create an Automation Account you need to consider which subscription you will use (if you have multiple subscriptions) and whether you will use an existing resource group or create a new one.
In this article, I will demonstrate how to create an Automation Account using the Web Portal and PowerShell.
First, log in to the Azure Web Portal. And once you’re logged in, click the Create a resource button.
Create a resource
From the Azure Market Place page, search for ‘Automation.’
Search for ‘Automation’
Once you are presented with the page to create the Automation account, click Create.
Click the ‘Create’ button
Then you will see the Add Automation Account form.
Fill in the name, subscription, and create resource group
Select the location
Now, wait for the Automation account to be created. Once the automation account is created, you can go to All Resources and verify that the Automation Account is listed in the list of resources.
Click on the All Resource button
The new Azure Automation Account is created
The first step is to choose which Azure subscription to use.
Open PowerShell and connect to Azure. Then select your Azure subscription by using these command:
Get-AzSubscription
Select-AzSubscription
Select an Azure Subscription
Next, create a resource group where the new Azure Automation Account will be created.
The command below will create the resource group with name Azure-AA-RG and the location is the EastUs region.
New-AzResourceGroup -Name 'Azure-AA-RG' -Location 'EastUS'
Creating a new resource group
Next, create the Automation Account. The command below will create the automation account with the name of Azure-AA, the location is EastUS and inside the resource group Azure-AA-RG
New-AzAutomationAccount -Name 'Azure-AA' -Location 'EastUS' -ResourceGroupName 'Azure-AA-RG'
Create a new automation account
In this article, you’ve learned how to login to Azure using the Portal and PowerShell. You also learned what the different Azure Automation resources are and how to create a new Azure Automation Account. You also gained a little insight on when and when not to use Azure Automation.
In the next article, I will show you how to create your first Azure Automation Runbook. Thank you for reading and stay tuned!
June has been in IT since 2004 and is currently an IT Engineer and Consultant by day. He's also a freelance writer, blogger, and coder. When not dabbling with tech stuff, he's mostly busy with his family, their dogs, and trying hard to be a mechanic.
Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.
Learn MoreSubscribe to get all the news, info and tutorials you need to build better business apps and sites