Introduction

Deploying applications manually can be time-consuming and error-prone. In modern development, Continuous Integration and Continuous Deployment (CI/CD) help automate the build, test, and deployment process.

Using GitHub Actions with Azure App Service, you can automatically deploy your .NET 9 application whenever you push code to your repository.

In this guide, you will learn how to set up a complete CI/CD pipeline for a .NET 9 application using GitHub Actions in a simple and practical way.

What is CI/CD?

CI/CD stands for:

In simple words:

"Push code → Automatically build → Automatically deploy"

Why Use GitHub Actions for .NET Deployment?

Prerequisites

Before starting, ensure you have:

Step 1: Create Azure App Service

Save:

Step 2: Download Publish Profile

From Azure Portal:

This file contains deployment credentials.

Step 3: Add Secrets in GitHub

Go to your GitHub repository:

Settings → Secrets → Actions

Add a new secret:

Step 4: Create GitHub Actions Workflow

Create a file:

.github/workflows/deploy.yml

Add the following configuration:

name: Deploy .NET 9 App to Azure

on:
  push:
    branches:
      - main

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Setup .NET
        uses: actions/setup-dotnet@v4
        with:
          dotnet-version: '9.0.x'

      - name: Restore dependencies
        run: dotnet restore

      - name: Build project
        run: dotnet build --configuration Release

      - name: Publish project
        run: dotnet publish -c Release -o publish

      - name: Deploy to Azure
        uses: azure/webapps-deploy@v2
        with:
          app-name: YOUR_APP_NAME
          publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
          package: publish

Step 5: Push Code to Trigger Deployment

git add .
git commit -m "Initial CI/CD setup"
git push origin main

GitHub Actions will:

Step 6: Monitor Deployment

Go to:

You can track:

Step 7: Enable Continuous Deployment

Now every time you push code:

No manual deployment needed.

Step 8: Best Practices for CI/CD in .NET

Difference Between Manual Deployment vs CI/CD

FeatureManual DeploymentCI/CD
SpeedSlowFast
ErrorsHighLow
AutomationNoneFull
ReliabilityMediumHigh

Real-World Workflow Example

Typical flow:

Conclusion

Using GitHub Actions with Azure App Service is one of the easiest and most powerful ways to implement CI/CD for .NET 9 applications. It automates your deployment process, reduces errors, and ensures faster delivery.

Start with a simple pipeline and gradually enhance it by adding testing, staging environments, and monitoring to build a production-ready DevOps workflow.