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?
Built into GitHub (no extra tools needed)
Easy YAML-based configuration
Seamless integration with Azure
Supports automation workflows
Prerequisites
Before starting, ensure you have:
Step 1: Create Azure App Service
Go to Azure Portal
Create a Web App
Choose .NET runtime
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:
Build your app
Publish it
Deploy it to Azure
Step 6: Monitor Deployment
Go to:
GitHub → Actions tab
View workflow logs
You can track:
Build success
Deployment status
Errors
Step 7: Enable Continuous Deployment
Now every time you push code:
CI runs automatically
CD deploys automatically
No manual deployment needed.
Step 8: Best Practices for CI/CD in .NET
Use environment-based configs (Dev, Staging, Prod)
Add unit tests before deployment
Use caching for faster builds
Secure secrets using GitHub Secrets
Monitor logs and alerts
Difference Between Manual Deployment vs CI/CD
| Feature | Manual Deployment | CI/CD |
|---|
| Speed | Slow | Fast |
| Errors | High | Low |
| Automation | None | Full |
| Reliability | Medium | High |
Real-World Workflow Example
Typical flow:
Developer pushes code to GitHub
GitHub Actions builds project
Runs tests
Deploys to Azure App Service
Application updates automatically
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.