1. Home
  2. Training Library
  3. Microsoft Azure
  4. Courses
  5. Microsoft Azure Automation: Concepts and Practical Usage

Demo: Build Runbooks with the Azure Automation ISE Add-on

Start course


Use the Azure Automation Authoring Toolkit, an add-on for the PowerShell Integrated Scripting Editor (ISE), to streamline the Azure Automation Runbook authoring process! Using bi-directional synchronization with your Azure Automation Account, you can easily import Runbooks that are already hosted in your cloud environment, upload Runbooks that you author locally on your Windows client, and even provision variable and PSCredential assets locally!


Hello. In this demonstration, we're going to take a look at how to use the Azure Automation ISE add-on to enhance our productivity while developing Automation runbooks.

I already have an Azure Automation account established inside of a resource group called "Cloud Academy Automation". We're going to connect to this Automation account so that we can manage the runbooks and assets that it contains.

Back in the PowerShell Integrated Scripting Editor, assuming that I'm running PowerShell version 5.0, I can call the Install Module command to install a module from the PowerShell Gallery. Now, if you don't know what the module's name is, you can start off by using the Find Module. So let's call Find Module-NameAzure. As you can see, we got back an array of modules from the PowerShell Gallery. Most importantly is the Azure Automation Authoring Toolkit one. That's the one that allows us to author runbooks inside of the PowerShell ISE.

We're going to go back to our Install Module command and tell it to install that module. We're also going to add the scope parameter, and tell it that we want to install the module only for our current user. Now, we get a warning saying that we're installing from an untrusted repository. But because we trust this particular module, we'll just go ahead and click Yes. Great.

So now we've installed the module. We can confirm that the module is installed by running Get-Module-List Available-NameAzure. So we'll hit F8 to run just line number five, and if we scroll up through our list of modules you'll see that we have the Azure Automation Authoring Toolkit module installed. So now that we've confirmed that the module is installed, let's call Import Module. So we'll call Import Module - Name, and then Azure Automation Authoring Toolkit.

Now, as soon as we import the module, it's going to install the add-on and make it available in the right-hand side of the PowerShell ISE. You can choose which directory to use for your working folder by changing the base path. You can also sign into Azure Automation to connect to your Automation account. That's a critical step in using the add-on.

So I'm going to type my Azure Active Directory credentials here, and sign in to Microsoft Azure. You'll see that the command actually queries for all Azure Automation accounts inside my subscription, not only the one that I want to connect to. So we're actually connecting to our entire Azure subscription.

So now I can drop this down and choose an Automation account that belongs to any resource group inside of my Azure subscription. If you have more than one subscription, you can change the subscription context with this combo box. The Azure Automation ISE add-on uses a certificate to encrypt to local assets, such as passwords or other critical information.

Let's go over to the Runbook tab. The Runbook tab shows us runbooks that are currently inside of our Azure Automation account. We can also create new runbooks locally, test them, and then upload them to the Automation account. Under Assets, we have a view of all our different connection, credential, variable, and certificate assets that are available inside the Automation account, and we can even create new assets from this add-on right here.

So let's go over to Runbooks and create a new runbook. Let's create a runbook called "Get Process", and we'll add a 2 at the end and we're going to tell it that we want to create a PowerShell script runbook. So inside that runbook, I'm simply going to run the Get Process command, and then select just the names of the processes.

Okay. So now I've created a runbook that has a very simple command inside of it. Now, I can go ahead and hit F5 to test that command, and it's going to run locally on my system. As we can see, we got the desired output from this command. So now, you can see in the runbook ISE add-on that we have that runbook only available in our local asset store. So what we need to do in order to use this in Azure is to click Upload Draft. The upload process is very quick, and if we switch back over to our portal we can refresh the view and confirm that that change actually took place.

Because runbooks are also considered Azure resources in addition to the Automation account itself, you can see that the Get Process 2 runbook has been made a direct child resource of the resource group that contains the Automation account as well. If we click on the Automation account and then go on over to the Runbooks section, we'll see it inside there as well.

So here's the Runbooks blade for our Automation account, and as you can see the Get Process 2 runbook is available. So let's click on that runbook to open its blade inside the portal. Let's click the Edit button to view the code for the runbook, and now that we can see the runbook code let's click on the test pane to test it out inside of Azure. We'll click the Start button to execute the runbook. As you can see, the runbook has been successfully tested and it's showing us the names of the processes.

There's another button that allows us to do the same operation of testing that runbook inside of Azure called "Test Draft in Azure". Now, when you click the Test Draft in Azure button, you'll be presented with a new window for testing. However, what's really cool is that the Automation ISE add-on actually brings in the results without having to retest the runbook.

We can delete a runbook by clicking the Delete button, and we'll be prompted if we just want to delete it from our local asset store or from the cloud and local disk as well. Great. So now we've cleaned up that extra runbook.

Now, let's go over to Assets. Now, I have a couple of credential assets already in here, and I also can select Connection, Variable, and Certificates. For Credentials, I have a credential called "Azure Admin" that allows me to access Azure resources. So I'm going to create a new runbook and actually authenticate to Microsoft Azure. So let's call this "Azure Auth Test" and we'll create a new script runbook.

Now, the first command I'm going to run is Add Azure RM Account, and I'm going to specify the credential as a PSCredential instance. Now, instead of typing the credentials inside the runbook, I'm going to go ahead and insert an asset. So I'm going to select the Azure Admin asset, and then I'm going to choose Insert. So that's going to automatically create the Get Automation PSCredential command that's special inside of the runbook execution environment, and it's going to pass in the Azure Admin parameter into the name parameter.

So now we're authenticated to Azure inside the runbook. So what's another command that we could run? Well, we could call Get-Azure RMResourceGroup, and that'll list out all of the resource groups inside our subscription. As you can see, our command ran successfully. So now, we can save this runbook that uses this credential asset called "Azure Admin" and upload it to our Automation account. So I'm going to choose the Azure Auth Test, and then click Upload Draft. Great.

Now, I'll come back to Assets and because I updated this asset locally, I'm going to go ahead and upload that to ensure that it's in sync. Great. So now the assets have been updated. So let's go ahead and test out the runbook inside of Azure. So I'll come back to the Runbooks tab, click the runbook, and then choose Test Draft in Azure. I'll click on the Start New Job button to invoke the execution. As you can see, the Azure Automation runbook has executed successfully and we're now getting back results from it. So that's just a really simple introduction to the Azure Automation ISE add-on.

About the Author

Trevor Sullivan is a Microsoft MVP for Windows PowerShell, and enjoys working with cloud and automation technologies. As a strong, vocal veteran of the Microsoft-centric IT field since 2004, Trevor has developed open source projects, provided significant amounts of product feedback, authored a large variety of training resources, and presented at IT functions including worldwide user groups and conferences.