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, andAZURE_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
How to Deploy to Google Cloud Run in GitHub ActionsDeploy a container to Google Cloud Run from GitHub Actions using Workload Identity Federation, pushing to Art…
How to Deploy an AWS Lambda with SAM in GitHub ActionsBuild and deploy a serverless app with AWS SAM from GitHub Actions, authenticating to AWS via OIDC so no long…