Running an Azure Automation runbook/script on demand from a button in Teams

Reply A+ A-

In this post I will show you how to execute an Azure Automation runbook or script on demand from a button in Teams.


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

This runbook contains a PowerShell script.

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

You want to run it directly from Teams.

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

- Create a Power Automate flow

- The flow runs the webhoot with POST method

- Add the Power Automate flow in Teams

Get the script

Click on the below GitHub picture to get the script

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 somewhere

7. Click on OK

Power Automate part

In this part we will create a flow that will call the webhook with a POST method.

We will proceed as below:

1. Go to Power Automate

2. Clic on Flows > New flow

3. Click on Instant cloud flow

4. Select Manually trigger a flow

5. Click on Create

6. Click on New step

7. In the search bar, type HTTP

8. Select HTTP

10. In Method, select POST

11. In Uri, type the webhook URL

12. Click on Save

13. Change the name of your flow

13. Click on Share

14. Share it with your teams mail

Adding the flow to Teams

1. Click on the + button

2. Search and click on Power Automate

4. Uncheck Post to the channel

5. Click on Save

6. Your previous flow will be available

7. Click on the play button

8. Click on Run flow

slider 7409976414283528884

Enregistrer un commentaire

Accueil item


Learn KQL in one month


You want to support me ?

Mes articles en français

Books in French