Azure Automation: Author Runbook Using PowerShell - Hello World

In our previous article (listed below), we have learned the basics of Azure Automation. In this article, we will learn how to create a basic Runbook.

Navigate to the essentials tab of the Azure Automation account by clicking the account name in the list of the Azure Automation Account, shown below:

Account
Click the account and you will be taken to the essentials tab of the Automation Account, as shown below:

Account

By default, the following are created.

  1. 2 Runbooks
  2. 17 Assets

Click Runbooks tile, as shown in the above screenshot. You will be taken to the list of Runbooks that were already created.

Account
Now, click “Add a runbook” link, as shown in the above screenshot:

Add a runbook

There are two methods, using which, you can create Runbooks. Let’s select “Quick Create” and provide the following values.

  1. Name: Name of the Runbook that we would like to create.
  2. Runbook type: For now, select “PowerShell” as the runbook type
  3. Description: Provide some meaningful description.

Click “Create”. In just a couple of seconds, the new Runbook named “HelloWorld” is created, as shown below:

Create
Please note that the “Authoring Status” of the new Runbook is “New”. As soon as you create Runbook, it will be opened and go to edit state, as shown below:

New

The highlighted part in the above screenshot is where you author your PowerShell code for the current Runbook.

Also, in the left hand section of the “Edit PowerShell runbook” blade, you will see the existing Runbooks, along with the Assets.

Edit

This means you can use these Runbooks and the assets; while authoring the current Runbook.

Let’s write some basic PowerShell code that writes the output “Hello World”, as shown below:

Hello World

Now, click “Test Pane”. You will be taken to a new blade, where you can test your Runbook, as shown below:

Test

Now, click “Start” button. Clicking “Start” button will submit RunBook to the Azure Automation Worker Server, which is responsible for executing Runbook. As shown below, after clicking the “Start” button, our “HelloWorld” Runbook is queued for the processing.

Test

After a few seconds, the states get changed from “Queued” to “Started” followed by “Running” and once the processing is complete; the output is shown below:

Test

That’s it. We have authored our first HelloWorld Runbook, using Azure Automation – PowerShell.

Up Next
    Ebook Download
    View all
    Learn
    View all