Using Azure Automation: Part 3

Doctor Scripto

Summary: Learn how to access Azure Automation assets within a runbook.

Honorary Scripting Guy, Sean Kearney, is here today to battle robots, aliens, and…

…No, wait, sorry. My brain lapsed from watching an old rerun of Lost in Space.

This is the third post in a five-part series. To catch up, read:

Today I will continue showing you how to get up and running with Azure Automation with a simple project of having a runbook to shutdown virtual machines in Azure.

Our previous runbook with the fully exposed credentials and a clear-text password looked like this (I sense far too many security specialists shaking their heads at this):

Image of script

We can mitigate all of this silliness now by inserting the asset from the Azure Automation that we created yesterday.

This is done by choosing the place in the runbook where we would like the asset, clicking Setting, and choosing Insert to select an asset. In the following example, I created a new line for assigning the $cred object that will be inserted in the code from Azure Automation:

Image of script

When I click Insert, a wizard appears, which allows us to choose the asset. It will also automatically build the needed cmdlet to access the asset.

In the following example, we are going to access our newly created object called AzureManagementCredentials. (Aren't you glad we gave it a useful name instead of something like TribbleFodder?)

Image of menu

When we return to the runbook, we'll see a new line of code appended to the $Cred= portion:

Image of script

We now delete the two lines of code in the previous runbook that used the UserID and Password to get this result.

Image of script

At this point, we click the Test button to confirm that everything is working properly in our script.

It seems to work, but we have nothing to tell us what, why, or how something happened? Come back tomorrow, and I'll show you some simple things to finish up this runbook and promote it in production!

I invite you to follow The Scripting Guys on Twitter and Facebook. If you have any questions, send an email to The Scripting Guys at, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then remember eat your cmdlets every day with a taste of creativity.

Sean Kearney, Windows PowerShell MVP and Honorary Scripting Guy


Discussion is closed.

Feedback usabilla icon