Skip to content
Public template

About

Probot & Azure Functions example

Resources

Code of conduct

Stars

3 stars

Watchers

2 watching

Forks

Repository files navigation

Probot & Azure Functions example

This repository is an example of how to deploy the "Hello, World" of probot apps to Azure Functions.

The app uses ES modules, the Azure Functions Node.js v4 programming model, and @probot/adapter-azure-functions v2 (Probot 14). The function is registered in function.js and receives webhooks at /api/ProbotFunction.

Local setup

Use Node.js 26 (see .nvmrc). Install dependencies and start the Probot development server:

npm install
npm start

Open http://localhost:3000 and follow instructions to register a GitHub App for testing. When done, an .env file with your app's credentials will exist.

To run the same handler in the Azure Functions host, install Azure Functions Core Tools v4, add FUNCTIONS_WORKER_RUNTIME=node and your Probot environment variables to the Values of a local.settings.json file (ignored by Git), and run func start.

Deploy to Azure

The ARM template provisions a Linux Function App on the Flex Consumption plan, storage, Application Insights, Log Analytics, a managed identity, and a Key Vault. Node.js 26 is currently in preview on Azure. These resources can incur charges; the vault has 90-day purge protection, so its name remains reserved after deletion.

Prerequisites:

  • An Azure subscription and the Azure CLI. The deployer needs permission to create resources and role assignments in the resource group.
  • Node.js 26, used to create the parameter file and build the application.
  • A GitHub App with a private key and webhook secret. Subscribe it to Issues events, grant Issues: Read and write, and install it on a repository.
  • A region that supports Flex Consumption and the Node.js 26 preview. After signing in, run az functionapp list-flexconsumption-locations --runtime node --show-details true --output json to inspect regional runtime versions.

From the repository root, add these values to a local .envrc file. The Function App name must be globally unique. Keep the PEM file private and outside the repository.

export RESOURCE_GROUP="probot-functions"
export LOCATION="eastus"
export FUNCTION_APP_NAME="<globally-unique-function-app-name>"
export GITHUB_APP_ID="<github-app-id>"
export PRIVATE_KEY_FILE="<path-to-github-app-private-key.pem>"
export WEBHOOK_SECRET='<github-app-webhook-secret>'

.envrc is ignored by Git but contains the secret in plaintext: restrict access and never commit or share it. Use shell quoting that preserves the exact secret; within the single-quoted value, write an embedded single quote as '\''. Disable shell tracing before loading or using secrets.

With direnv configured in your shell, restrict access to the file and approve it:

chmod 600 .envrc
direnv allow

Once direnv loads the variables, sign in and create the resource group. Alternatively, in Bash you can run source .envrc if the file contains only shell assignments.

az login
az account set --subscription "<subscription-id>"
az group create --name "$RESOURCE_GROUP" --location "$LOCATION"

Alternatively, omit WEBHOOK_SECRET from .envrc and enter it in Bash without recording it in your shell history:

IFS= read -r -s -p "GitHub App webhook secret: " WEBHOOK_SECRET; printf '\n'; export WEBHOOK_SECRET

Create a temporary, permission-restricted parameter file using the script. It reads GITHUB_APP_ID, PRIVATE_KEY_FILE, and WEBHOOK_SECRET from the environment, encodes the key locally, and prints the file path. Resolve any errors before continuing.

PARAMETERS_FILE="$(./scripts/create-deployment-parameters.sh)"

Preview the resources and review the result before deploying:

az deployment group what-if \
  --resource-group "$RESOURCE_GROUP" \
  --template-file infra/azuredeploy.json \
  --parameters "@$PARAMETERS_FILE" "functionAppName=$FUNCTION_APP_NAME" "location=$LOCATION" \
  --result-format ResourceIdOnly --no-prompt true

Deploy the infrastructure. The output includes the webhook URL; the application code must be deployed separately using the CLI or GitHub Actions below.

az deployment group create \
  --name probot-functions \
  --resource-group "$RESOURCE_GROUP" \
  --template-file infra/azuredeploy.json \
  --parameters "@$PARAMETERS_FILE" "functionAppName=$FUNCTION_APP_NAME" "location=$LOCATION" \
  --no-prompt true --query properties.outputs --output json

Remove the temporary parameter file, including if deployment fails:

rm -f -- "$PARAMETERS_FILE"

You can run unset WEBHOOK_SECRET to clear it from the shell; this does not remove a copy stored in .envrc.

The template stores the credentials as Key Vault secrets and configures the app to use managed-identity references. Rerunning the template requires the current credentials and updates those secrets. Versionless references refresh within 24 hours; see Key Vault reference rotation to refresh sooner. Role assignments can take time to propagate; if deployment or reference resolution initially fails, wait and retry.

Deploy the application from the command line

Install Azure Functions Core Tools v4 and use Node.js 26. Sign in with az login and select the subscription containing the Function App. From the repository root, copy only the application files into a temporary directory, install production dependencies, and publish:

: "${FUNCTION_APP_NAME:?Set FUNCTION_APP_NAME before publishing}" &&
PUBLISH_APP_NAME="$FUNCTION_APP_NAME" &&
PUBLISH_DIR="$(mktemp -d)" &&
cp app.js function.js host.json package.json package-lock.json "$PUBLISH_DIR/" &&
(
  cd "$PUBLISH_DIR" &&
  npm ci --omit=dev &&
  : "${PUBLISH_APP_NAME:?Function App name is empty}" &&
  FUNCTIONS_WORKER_RUNTIME=node func azure functionapp publish "$PUBLISH_APP_NAME" --no-build
)

The app name is captured before entering the temporary directory. This publishes the current local application files without uploading .envrc, local.settings.json, or the Git repository. The command does not publish local settings; the infrastructure deployment configures the app settings. The temporary directory can be removed after publishing.

Check that Azure registered the function:

az functionapp function list --resource-group "$RESOURCE_GROUP" \
  --name "$FUNCTION_APP_NAME" --query '[].name' --output table

The list should include ProbotFunction. If it is empty, check the publish output and the Function App's startup logs before testing the webhook.

Deploy the application with GitHub Actions

In the repository's Settings > Secrets and variables > Actions:

  1. Set the repository variables AZURE_FUNCTION_APP_NAME to the Function App name and AZURE_FUNCTION_USE_RBAC to true.
  2. Set the AZURE_CREDENTIALS secret to a service principal credential with the Website Contributor role on the Function App. Rotate this credential when it expires.

Run the Deploy workflow, or push to main. For an existing publish-profile deployment, leave AZURE_FUNCTION_USE_RBAC unset and retain the AZURE_FUNCTION_APP_PUBLISH_PROFILE secret; the app name defaults to probot-example.

Verify the webhook

Set the GitHub App's webhook URL to the template's webhookUrl output and its webhook secret to the same value supplied above. After deploying the application, open an issue in an installed repository and verify that the app comments "Hello, World!".

License

ISC

About

Probot & Azure Functions example

Resources

Code of conduct

Stars

3 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages