Loading...

Run an Azure Automation runbook on demand without going to the portal

Reply A+ A-


In this post I will show you how to run an Azure Automation runbook on demand from your device.


Context

You have created a script (Runbook) in Azure Automation.

You want to be able, or let someone of your team, to run it on demand without going to the Azure portal.

You have created an Azure Automation runbook

This runbook contains a PowerShell script

You want to run it when you want without going to the Azure portal


The solution

The solution is super easy, we will proceed as below:

- Create an Azure Automation account

- Add a script as Runbook

- Add a webhook on your runbook

- Call the webhook on your own device


Azure Automation part

Creating the account

1. Go to Azure

2. In the search bar type: Automation accounts

3. Go to Automation accounts

4. Click on Create

5. Type a name

6. Choose a Subscription

7. Choose a Resource group

8. Choose a region

9. In Create Azure Run As Account, select No

10. Click on Create


Adding your script

In the below example we will just add a script that will sync a specific device.

We will proceed as below:

1. Go to Runbook

2. Copy the content of your script

3. Click on Publish


Add a webhook

1. Go to your Runbook

2. Click on Add webhook

3. Click on Create new webhook


4. Type a name

5. Set it to Enabled

6. Copy the webhook URL

7. Click on OK



Run it on demand

I my case I added a simple script in my runbook that will just a syncdevice action on a device.

Copy the webhook URL in a variable $webhookURI.

Run the below script:

It's also possible to pass argument to the webhook.

slider 1982239724646838005

Enregistrer un commentaire

Accueil item

Award

Sponsors

You want to support me ?

Mes articles en français

Author of Books


Stats