Deploy Azure Web App Workflow

March 26, 2026 ยท View on GitHub

This reusable GitHub Actions workflow automates the process of deploying applications to Azure Web App. It supports deploying both .NET applications and SPA (Single Page Application) projects, with the ability to handle persisted documents and multiple deployment slots.

Functionality Summary

The Deploy Azure Web App workflow includes the following features:

  • Artifact Deployment:

    • Downloads and deploys .NET application artifacts
    • Optionally deploys SPA artifacts to the wwwroot folder
    • Optionally deploys persisted documents file(s) to the root folder
  • Azure Integration:

    • Authenticates with Azure using OIDC
    • Deploys to specified Azure Web App
    • Supports deployment to different slots (e.g., Production, Staging)
  • Environment Management:

    • Configurable environment names for deployment
    • Supports different configurations per environment

Configuration Options

Workflow Inputs

Input NameDescriptionRequiredDefault Value
environment_nameEnvironment name for deploymentYesNone
artifact_nameName of the .NET artifact to deployNo.net-app
spa_artifactName of the SPA artifact to deploy in wwwroot folderNoNone
persisted_documents_artifactName of the persisted documents artifact to deployNoNone
azure_client_idClient ID for Azure deploymentNoNone
azure_tenant_idTenant ID for Azure deploymentNoNone
azure_subscription_idSubscription ID for Azure deploymentNoNone
azure_webapp_nameAzure Web App name for deploymentNoNone
azure_webapp_slot_nameAzure Web App slot name for deploymentNoNone
delete_destinationEmpty destination folder before deploymentNotrue

Required Variables or Inputs

The workflow requires the following Azure configuration values to be provided either as:

  • Workflow inputs (as shown in the table above), or
  • Repository/Environment variables with these names:
Variable NameDescriptionRequiredDefault Value
AZURE_CLIENT_IDClient ID for Azure deploymentYesNone
AZURE_TENANT_IDTenant ID for Azure deploymentYesNone
AZURE_SUBSCRIPTION_IDSubscription ID for Azure deploymentYesNone
AZURE_WEBAPP_NAMEAzure Web App name for deploymentYesNone
AZURE_WEBAPP_SLOT_NAMEAzure Web App slot name for deploymentNoProduction

The workflow will first check for values provided as inputs, and if not found, will fall back to repository or environment variables. If neither is available, the workflow will fail with a validation error.

Example Usage Scripts

1. Deploy .NET Application

name: Deploy to Production

on:
  push:
    branches:
      - main

jobs:
  deploy:
    uses: Shane32/SharedWorkflows/.github/workflows/deploy-azurewebapp.yml@v2
    permissions:
      contents: read
      id-token: write
    with:
      environment_name: Production

The above example assumes that the necessary Azure configuration values are stored as GitHub environment variables.

2. Deploy Full Stack Application to Staging Slot

name: Deploy to Staging

on:
  pull_request:
    branches:
      - main

jobs:
  deploy:
    uses: Shane32/SharedWorkflows/.github/workflows/deploy-azurewebapp.yml@v2
    permissions:
      contents: read
      id-token: write
    with:
      environment_name: Staging
      artifact_name: backend-build
      spa_artifact: frontend-build
      persisted_documents_artifact: persisted-docs
      azure_webapp_name: my-production-app
      azure_webapp_slot_name: Staging
      azure_client_id: ${{ secrets.AZURE_STAGING_CLIENT_ID }}
      azure_tenant_id: ${{ secrets.AZURE_STAGING_TENANT_ID }}
      azure_subscription_id: ${{ secrets.AZURE_STAGING_SUBSCRIPTION_ID }}

The above example shows how to provide Azure configuration values as workflow inputs, pulling from repository secrets.

Notes

  • The workflow uses OIDC (OpenID Connect) for secure authentication with Azure
  • The permissions: id-token: write is required for Azure deployment workflows to enable OIDC authentication with Azure.
  • SPA artifacts are automatically deployed to the wwwroot folder when specified
  • Perisisted document artifacts are automatically deployed to the root folder when specified
  • All artifacts must be previously created and available in the workflow run

Warning

By default, delete_destination is set to true, which deletes all existing files in the destination folder before deploying the updated application code. This will permanently delete any local databases (e.g., SQLite .db files) or other data files stored on the server. Set delete_destination: false if the application stores data locally on the server that must be preserved across deployments.