Back to APIs

Microsoft Azure

azure.microsoft.com

Manage your Azure resources, storage, and compute resources.

Using the Microsoft Azure API with Trigger.dev

You can use Trigger.dev with any existing Node SDK or even just using fetch. Using io.runTask makes your Microsoft Azure background job resumable and appear in our dashboard.

Use io.runTask() and the official SDK or fetch.

Use our HTTP endpoint to subscribe to webhooks

Example code using Microsoft Azure

Below is a working code example of how you can use Microsoft Azure with Trigger.dev. These samples are open source and maintained by the community, you can copy and paste them into your own projects.

1
import { TriggerClient } from "@trigger.dev/sdk";
2
import { parse } from "url";
3
4
// Documentation
5
// https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/activity-log-alerts-webhook
6
// https://learn.microsoft.com/en-us/azure/service-health/service-health-alert-webhook-guide
7
8
// Steps
9
// Goto Azure Monitor > Alerts > Create Action Group
10
// Fill up Basics with any data. In Actions, select Webhook and add the trigger endpoint with secret query param. Example: https://<Endpoint>?secret=123 then review and create.
11
// Goto Alerts Action groups and select the action group you created and click on the text action group. Select any sample type and test.
12
13
// Create an HTTP Endpoint, with the azure details
14
const azure = client.defineHttpEndpoint({
15
id: "azure.com",
16
title: "azure",
17
source: "azure.com",
18
icon: "azure",
19
verify: async (request) => {
20
const { query } = parse(request.url, true);
21
if (query.secret === process.env.AZURE_WEBHOOK_SECRET) {
22
return { success: true };
23
}
24
return { success: false, message: "Verification failed" };
25
},
26
});
27
28
// A job that runs when the HTTP endpoint is called from Azure Monitoring Alerts
29
client.defineJob({
30
id: "http-azure",
31
name: "HTTP Azure",
32
version: "1.0.0",
33
enabled: true,
34
// Create a trigger from the HTTP endpoint
35
trigger: azure.onRequest(),
36
run: async (request, io, ctx) => {
37
const body = await request.json();
38
await io.logger.info(`Body`, body);
39
},
40
});