CI/CD Pipelines
Continuous delivery turns every merged change into a tested, deployable release. GitHub Actions can deploy to Azure without storing any passwords.
On this page · 5 min · Advanced
On this page
- Learning objectives
- Explanation
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Advanced
- Updated
- Oct 29, 2026
Related tutorials
Learning objectives#
- Authenticate to Azure from GitHub with OIDC
- Build, test and deploy in one workflow
- Use environments and approvals
- Deploy safely with slots
Explanation#
OpenID Connect (OIDC) federation lets a workflow exchange a short-lived GitHub token for an Azure token. You configure a federated credential on an app registration or user-assigned managed identity — no client secret is stored.
The azure/login action signs in; azure/webapps-deploy deploys the build output.
GitHub environments add protection rules such as required reviewers before production.
Deploying to a staging slot first, then swapping, gives zero-downtime releases and instant rollback.
Code example: Deploy an API with OIDC#
name: deploy-api
on: { push: { branches: [main] } }
permissions: { id-token: write, contents: read }
jobs:
deploy:
runs-on: ubuntu-latest
environment: production # requires approval if configured
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with: { dotnet-version: '9.0.x' }
- run: dotnet test -c Release
- run: dotnet publish src/Shop.Api -c Release -o ./publish
- 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/webapps-deploy@v3
with: { app-name: app-shop-api, slot-name: staging, package: ./publish }
- run: az webapp deployment slot swap -g rg-shop-prod -n app-shop-api --slot staging
Tests pass → the build deploys to the staging slot → staging is swapped into production with no downtime.
This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.
Step-by-step explanation#
- id-token: write lets the job request an OIDC token.
- The three IDs are not secrets in the password sense, but storing them as secrets keeps workflows tidy.
- The app deploys to staging first.
- Swapping moves the warmed-up staging version into production.
Real-world use case#
Every merged pull request reaches production within minutes, with a human approval gate and instant rollback by swapping back.
Common mistakes#
Secrets expire and leak. OIDC federation removes them entirely.
Deploy to a slot, verify, then swap.
Best practices#
- Use OIDC federation
- Run tests before deploying
- Protect production with environment approvals
- Deploy to slots and swap
Remember this#
OIDC = no secrets in GitHub.
Test → deploy to staging → swap.
Rollback = swap back.
Practice exercise#
Your task: Add a step that checks the staging slot health endpoint before swapping.
Show solution
- run: curl --fail --retry 5 --retry-delay 5 https://app-shop-api-staging.azurewebsites.net/health
Mini quiz#
Which workflow permission is needed for OIDC login to Azure?
Want more? Practise all Microsoft Azure MCQs · Microsoft Azure interview questions
My notes#
Saved in this browser.