Deploy a .NET Core Application on Azure App Service Using GitHub Actions CI/CD
Here's a step-by-step guide for deploying a .NET Core application to Azure App Service using GitHub Actions for CI/CD:
Here is the general architecture diagram that we will be deploying.
Step 1: Prerequisites
Set Up Azure Resources:
- Log in to the Azure portal.
- Create an Azure App Service for hosting the application.
- Create an Azure Container Registry (ACR) to store your container images.
Set Up Your GitHub Repository:
- Ensure your .NET Core application is hosted in a GitHub repository.
- Include a
Dockerfile
in the root of your project for containerization (example provided in Step 2).
Install Azure CLI (if not already installed):
- Download and install the Azure CLI.
Login to Azure CLI:
Step 2: Add a Dockerfile to Your Project
- Navigate to the root of your .NET Core application.
- Create a
Dockerfile
for containerizing your application:Replace
YourAppName.dll
with the name of your.dll
file.
Step 3: Push Your Code to GitHub
- Commit your changes:
Step 4: Configure Azure Container Registry (ACR)
Log in to Azure ACR:
Get ACR Details:
Note down the ACR
loginServer
.
Step 5: Create a GitHub Actions Workflow
- In your GitHub repository, create a
.github/workflows/ci-cd.yml
file. - Add the following workflow configuration:
Replace placeholders like
<ACR_LOGIN_SERVER>
,<IMAGE_NAME>
, and<APP_SERVICE_NAME>
with your actual values.
Step 6: Set Up GitHub Secrets
- In your GitHub repository, go to Settings > Secrets and Variables > Actions.
- Add the following secrets:
AZURE_ACR_USERNAME
: Azure Container Registry username.AZURE_ACR_PASSWORD
: Azure Container Registry password.AZURE_APP_SERVICE_PUBLISH_PROFILE
: Download the publish profile from Azure App Service and paste its contents here.
Step 7: Test the Workflow
- Push a code change to the
main
branch. - Check the Actions tab in GitHub to monitor the CI/CD pipeline.
Step 8: Quality Assurance (QA)
- After the deployment to the DEV environment, test the application.
- Ensure all QA validations pass.
Step 9: Deploy to Production
- Update the GitHub Actions workflow to include a manual approval step before deployment to production.
- Add an environment in GitHub (
Settings > Environments
) namedProduction
and require approvals.
Step 10: Monitor and Scale the Application
- Use the Azure Portal to monitor application performance.
- Scale the App Service plan as needed for handling production traffic.
🌟 Master Microsoft Azure with Microsoft Azure in Action! 🌟
Dive into the world of cloud computing and supercharge your skills! This practical guide is packed with step-by-step tutorials, real-world use cases, and the latest Azure features to help you build, deploy, and manage scalable cloud apps like a pro. 🚀
🔥 Exclusive Deal Alert! Unlock amazing savings of 34.04% today! 🎉 Don’t miss this chance to learn Azure while saving big.
👇 Click now to claim your discount and start your Azure journey! 👇
👉 Grab Your 34% Discount Now!
Hurry—this offer won't last forever! ⏳