Skip to content
Latchkey

How to Deploy to Azure Functions in GitHub Actions

The Azure functions-action handles the zip-deploy; the trick is logging in with a federated credential instead of a publish profile.

Use azure/login with OIDC federated credentials, build the function, then Azure/functions-action to deploy the package.

Steps

  • Create an app registration with a federated credential for your repo.
  • Store AZURE_CLIENT_ID, AZURE_TENANT_ID, and AZURE_SUBSCRIPTION_ID.
  • Build the function app.
  • Deploy with Azure/functions-action.

Workflow

.github/workflows/azure-functions.yml
name: Deploy Functions
on:
  push:
    branches: [main]
permissions:
  id-token: write
  contents: read
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: '20' }
      - run: npm ci && npm run build
      - uses: azure/login@v2
        with:
          client-id: ${{ secrets.AZURE_CLIENT_ID }}
          tenant-id: ${{ secrets.AZURE_TENANT_ID }}
          subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
      - uses: Azure/functions-action@v1
        with:
          app-name: my-func-app
          package: .

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →