Azure Automation account — scheduling and webhook

Michal Molka
2 min readAug 30, 2024

--

In the last post we’ve created a runbook which starts or deallocates a VM. Azure Autmation Account — Powershell Start Stop VM

Today we do something useful with it. Before we make any further step, we need to publish the runbook.

A SCHEDULE

Switch over to a Schedule section. And set when do you want your function to run…

…and set values for all the parameters.

A WEBHOOK

The second way we can run the runbook is the webhook. Go to a Webhooks section. Set a name, copy a URL, set parameters and an expiration date.

Now, we are able to run the runbook by a POST request.

https://3*****e.webhook.we.azure-automation.net/webhooks?token=7*******d

We run it from a C# code.

In a Jobs section you can check the run out.

using System;
using System.Net.Http;

namespace csharp_examples;
class Program
{
public static async Task Main()
{
HttpClient client = new HttpClient();
var values = new Dictionary<string, string>
{
{ "resourceGrooupName", "c***m" },
{ "vmName", "c***1" }
};

var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync("https://3*****e.webhook.we.azure-automation.net/webhooks?token=7***d", content);
var responseString = await response.Content.ReadAsStringAsync();
}
}

--

--

Michal Molka

Architect | Azure | Power BI | Fabric | Power Platform | Infrastructure | Security | M365