Adapter to run a Probot application function in Azure Functions
This package is ESM-only and supports Azure Functions v4. Set "type": "module"
in your application's package.json or use .mjs files for your functions.
When upgrading, replace createAzureFunctionV4 with createAzureFunction.
The former createAzureFunction v3 handler is no longer supported.
Create your Probot application:
// src/app.js
export default (app) => {
app.on("issues.opened", async (context) => {
const params = context.issue({ body: "Hello World!" });
await context.octokit.issues.createComment(params);
});
};In your Azure function file:
// src/functions/probot.js
import { app } from "@azure/functions";
import {
createAzureFunction,
createProbot,
} from "@probot/adapter-azure-functions";
import probotapp from "../app.js";
app.http("probot", {
methods: ["POST"],
authLevel: "anonymous",
handler: createAzureFunction(probotapp, {
probot: createProbot(),
}),
});The app starts loading when the handler is created. Each request waits for the
same load to finish; load failures are logged and propagated to the invocation.
Set WEBHOOK_SECRET to the secret configured for your GitHub App.
Webhooks must include X-GitHub-Delivery, X-GitHub-Event, and
X-Hub-Signature-256. Missing headers return HTTP 400 with a JSON error.
Successful deliveries return HTTP 200 with {"ok":true}. Invalid signatures
and application errors are propagated to Azure Functions.
For an example Probot App continuously deployed to Azure Functions, see https://github.com/probot/example-azure-function/#how-it-works
@probot/adapter-azure-functions exports everything that probot does plus createAzureFunction.
createAzureFunction slightly differs from Probot's built-in createNodeMiddleware, as an Azure function receives different parameters.