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:
Click the account and you will be taken to the essentials tab of the Automation Account, as shown below:
By default, the following are created.
- 2 Runbooks
- 17 Assets
Click Runbooks tile, as shown in the above screenshot. You will be taken to the list of Runbooks that were already created.
Now, click “Add a runbook” link, as shown in the above screenshot:
There are two methods, using which, you can create Runbooks. Let’s select “Quick Create” and provide the following values.
- Name: Name of the Runbook that we would like to create.
- Runbook type: For now, select “PowerShell” as the runbook type
- Description: Provide some meaningful description.
Click “Create”. In just a couple of seconds, the new Runbook named “HelloWorld” is created, as shown below:
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:
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.
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:
Now, click “Test Pane”. You will be taken to a new blade, where you can test your Runbook, as shown below:
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.
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:
That’s it. We have authored our first HelloWorld Runbook, using Azure Automation – PowerShell.