<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1678611822423757&amp;ev=PageView&amp;noscript=1">
Defrag This

| Read. Reflect. Reboot.

Getting Started with Azure Automation: Introduction

June Castillote| November 21 2019

| IT insights, Automation, Sysadmin

getting-started-with-azure-automation-introduction

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.

What is Azure Automation

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.

Learn how to automate IT tasks with PowerShell. Download this eBook. 

When to use Azure Automation

There could be many reasons why Azure Automation can be used. These are some of the things you may want to consider.

  • When the task does not require user interaction.
  • When the task is repetitive.

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.

What You Need to Work with Azure Automation

In this series, there will be demos and examples. You need to have the following to effectively follow along.

  • Working knowledge of Azure.
  • You must be able to read, understand and write PowerShell scripts.
  • An Azure subscription. If you do not have this yet, you can sign up for a free trial
  • A computer with PowerShell 5.1 (or above).
  • The Azure PowerShell Module must be installed. If you don’t have this yet, please go to the Install the Azure PowerShell module page for more information.

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.

Logging in to Azure

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.

Not 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.

Login using the Portal

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.

intro to azure automation 1

Enter your username

Then you will be asked to enter your password, click Sign in.

intro to azure automation 2

Enter your password

And you will be taken to the Microsoft Azure homepage.

intro to azure automation 3

Microsoft Azure homepage

Login Using PowerShell

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.

intro to azure automation 4

Enter your username

intro to azure automation 5

Enter your password

Once login is successful, you will see a similar output as shown below in the PowerShell console.

intro to azure automation 6

Login to Azure is successful

Knowing the Different Azure Automation Resources

There are five (5) Azure automation resources that you must be familiar with. Below are the short descriptions for each.

intro to azure automation 7

Subscription

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.

intro to azure automation 8

Resource Group

 

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.

intro to azure automation 9

Automation Account

 

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.

intro to azure automation 10

RunBook

 

A runbook is simply a PowerShell script that runs in Azure. It is what’s in the center of your automation projects.

intro to azure automation 11

Asset

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.

Creating a New Azure Automation Account

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.

Create an Automation Account using the Portal

First, log in to the Azure Web Portal. And once you’re logged in, click the Create a resource button.

intro to azure automation 12

Create a resource

From the Azure Market Place page, search for ‘Automation.’

intro to azure automation 13

Search for ‘Automation’

Once you are presented with the page to create the Automation account, click Create.

intro to azure automation 14

Click the ‘Create’ button

Then you will see the Add Automation Account form.

  1. Give the automation account a name. I will use the name Azure-AA.
  2. Next, select the Subscription to use. I am using my Visual Studio Enterprise.
  3. Click on the Create new link to create a new resource group where the automation account will be created.
  4. Type in the name of the new resource group. I am using Azure-AA-RG.
  5. Then click OK.

intro to azure automation 15

Fill in the name, subscription, and create resource group

  1. Next, select the location appropriate to you. I am using the East US region as the location.
  2. Click Create

intro to azure automation 16

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.

intro to azure automation 17

Click on the All Resource button

intro to azure automation 18

The new Azure Automation Account is created

Create an Automation Account using PowerShell

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 <subscription name>

intro to azure automation 19

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'

intro to azure automation 20

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'

intro to azure automation 21

Create a new automation account

Summary

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!

New Call-to-action

Topics: IT insights, Automation, Sysadmin

Leave a Reply

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

THIS POST WAS WRITTEN BY June Castillote

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.

Free Trials

Getting started has never been easier. Download a trial today.

Download Free Trials

Contact Us

Let us know how we can help you. Focus on what matters. 

Send us a note

Subscribe to our Blog

Let’s stay in touch! Register to receive our blog updates.