Tag Archives: Azure Automation

Azure Automation – Start Azure runbooks from your own computer with PowerShell

I have been using Orchestrator for a few year and SMA also. But SMA didn’t really take off at many customers due to the requirements of Azure Pack. However i recently started looking to Azure Automation because i really like it. So i will start doing some blogposts about Azure Automation now. As i am kind of new to this some posts will be really basic but as i progress to more advance runbooks etc. the posts will advance also.

The first post will be how can you connect with PowerShell to Azure Automation. This can be done with at least two-way. One is that you enter your own credentials and the other is with certificate.

Before you start you have to download the Azure PowerShell cmdlets. They can be found here: http://go.microsoft.com/fwlink/p/?linkid=320376&clcid=0x409

Enter your own credentials

This way might not be the best if you want to automate something that requires your own credentials. I recommend using certificate. However it’s easy to do this way.

Just enter the command

Now a browser till open and you can sign in to your account

To verify that it worked you can now run

The account you just added should be listed now.

Using Certificate

Run the command

A Internet browser will open and you have to login to azure and a certificate file will be downloaded.

When the file is downloaded we have to import it into our certificate storage.

To verify that the certificate is active we can run get-azureAccount

And the output should be something like this.

Id Type Subscriptions Tenants

— —- ————- ——-

BFB4C2F0B3A6000000009AE56D87F0C46B1C639BB6 Certificate 0e0000-e6de-40009f-b000c-a751f000bb651

We can also open a mmc.exe and load the certificate plugin and check the personal storage.

So what can we do now?

There are lots of commands we can utilize just see the list below.

For this post i will just show how we can call on a runbook in Azure from our computer.

    1. Create a runbook in Azure Automation

For this example i am using a parameter in the script to show you how we can pass a paramenter from our on-premis to Azure runbook. Remember to publish the runbook after you are done typing in the code.

workflow HelloWorld

In order to call the runbook from PowerShell we need to know the name of our AzureAutomation Account. You can see this easy on the portal.

  1. Start the runbook

Now we can call the runbook from PowerShell.

And if we look in the portal we can see the runbook is starting.

Why do we want to call a runbook from PowerShell on-prem?

Well i won’t go into details here but there are many reasons why we would like to do this. One example is if we have a Offering in Service Manager for example that is provision a new Azure VM. There is no AzureAutomation Connector so we can talk direct to Azure. But we could use a normal Orchestrator runbook or SMA-Runbook to call on AzureAutomation.