DEV Community

Cover image for Supercharge Your Deployments: GitHub Actions + Azure Web App CI/CD
Eduardo Calzone
Eduardo Calzone

Posted on

Supercharge Your Deployments: GitHub Actions + Azure Web App CI/CD

πŸ“Œ Note: This post is based on the source code used in my previous article
πŸ‘‰ Simple Email Sending API with .NET

πŸ”„ What is CI/CD?

CI/CD stands for Continuous Integration and Continuous Delivery (or Continuous Deployment). It’s a set of modern DevOps practices that help teams deliver software faster, safer, and more frequently by automating the build, test, and deployment process.


πŸ”§ Continuous Integration (CI)

CI is all about merging code early and often. Developers push changes to the main branch multiple times a day. Each push triggers automated builds and tests, helping catch bugs and integration issues before they grow into bigger problems.

Benefits:

  • βœ… Catch errors early
  • βœ… Keep the codebase stable
  • βœ… Make collaboration easier

πŸš€ Continuous Delivery (CD)

CD ensures your app is always ready to deploy. Every change that passes CI is automatically pushed to a staging or test environment. Deploying to production is just one manual click away.

Benefits:

  • ⚑ Faster release cycles
  • πŸ“‰ Reduced deployment risks
  • πŸ§ͺ Quick feedback from stakeholders

⚑ Continuous Deployment

This takes CD to the next level: every passing change goes straight to productionβ€”no manual steps required.

Benefits:

  • πŸ” Real-time updates
  • πŸ€– Maximum automation
  • ⏱️ Ultra-fast reaction to bugs or market needs

To pull this off, your test suite needs to be rock solid. Continuous Deployment is the endgame for teams aiming to ship confidently, quickly, and often.


βš™οΈ What is GitHub Actions?

GitHub Actions is a CI/CD (Continuous Integration and Continuous Delivery) tool built into GitHub. It lets you automate tasks like building, testing, and deploying your code every time you push to a repository.


πŸ”§ What Can You Do With GitHub Actions?

  • βœ… Run tests automatically on each commit or pull request
  • πŸš€ Deploy your app to cloud platforms (e.g., Azure, AWS, Heroku)
  • πŸ“¦ Build and publish Docker images
  • 🧹 Run code formatters, linters, or cleanup scripts
  • πŸ§ͺ Set up custom workflows for any automation

🧠 Why Use It?

πŸ”— Fully integrated with GitHub

πŸ“ˆ Scales with your project

πŸ™Œ Community-driven (tons of reusable actions)

πŸ’Έ Free minutes included with GitHub plans

If you’re already using GitHub to manage your code, GitHub Actions is a powerful and easy way to automate your entire dev lifecycle.

πŸ› οΈ Real-World CI/CD Example with Azure and GitHub

In the following step-by-step guide, we'll walk through a real-world scenario on how to implement a CI/CD pipeline in Azure for a web application hosted in a GitHub repository. These are the steps:

πŸš€ Create an Azure Web App

Go to https://portal.azure.com and create a new Azure Web App.

Before that, make sure to:

  • βœ… Create a Subscription (if you don't already have one)
  • βœ… Set up a Resource Group to organize your resources

Once these are ready, you can proceed with configuring your web app (choose runtime, region, and plan as needed).





βš™οΈ Enable Continuous Deployment

We chose to Enable Continuous Deployment. This allows us to select the GitHub repository we want to deploy from directly.

During this step:

  • πŸ”— You'll be prompted to authorize GitHub and select your repository and branch.
  • πŸ” It's important to Enable Basic Authentication to allow Azure to access your GitHub repo securely.

Once completed, Azure will automatically pull and deploy changes from your repository whenever you push new commits.



🌐 Configure Access Settings

For the purposes of this tutorial, I selected Enable Public Access.

This allows anyone to access the web app via its public URL, which is useful for testing and demonstration.

⚠️ Note: In a production environment, you may want to restrict access using authentication, IP restrictions, or a private network setup.



πŸ’‘ Extra Tip: Enable Application Insights

As an extra tip, you can enable Application Insights during setup.

Since our code uses the ILogger interface, this allows us to take full advantage of Azure's built-in monitoring and logging features.

With Application Insights, you’ll be able to:

  • πŸ” Track requests, dependencies, and exceptions
  • πŸ“Š Analyze performance and response times
  • πŸ“ˆ Gain insights into user behavior and application usage

Enabling it now saves time later when debugging or optimizing your app.



βœ… Final Step: Review and Create

Click on Review + Create to finalize the app setup.

Once the deployment is complete:

  1. Go to your newly created Web App in the Azure Portal.
  2. Add the necessary environment variables for your project.

πŸ›  These variables might include database connection strings, API keys, or other project-specific settings required at runtime.



πŸ“„ GitHub Actions Workflow File

After completing the deployment setup, a .yml file is automatically generated in your project’s GitHub repository.

This file defines your CI/CD pipeline and typically follows a structure like this:

name: Build and deploy ASP.Net Core app to Azure Web App - emailsenderapi

on:
  push:
    branches:
      - master
  workflow_dispatch:

jobs:
  build:
    runs-on: windows-latest
    permissions:
      contents: read #This is required for actions/checkout

    steps:
      - uses: actions/checkout@v4

      - name: Set up .NET Core
        uses: actions/setup-dotnet@v4
        with:
          dotnet-version: '9.x'

      - name: Build with dotnet
        run: dotnet build --configuration Release
      - name: Run tests
        run: dotnet test --configuration Release --no-build --verbosity normal
      - name: dotnet publish
        run: dotnet publish -c Release -o "${{env.DOTNET_ROOT}}/myapp"

      - name: Upload artifact for deployment job
        uses: actions/upload-artifact@v4
        with:
          name: .net-app
          path: ${{env.DOTNET_ROOT}}/myapp

  deploy:
    runs-on: windows-latest
    needs: build
    environment:
      name: 'Production'
      url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

    steps:
      - name: Download artifact from build job
        uses: actions/download-artifact@v4
        with:
          name: .net-app

      - name: Deploy to Azure Web App
        id: deploy-to-webapp
        uses: azure/webapps-deploy@v3
        with:
          app-name: 'emailsenderapi'
          slot-name: 'Production'
          package: .
          publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE }}
Enter fullscreen mode Exit fullscreen mode

πŸš€ Testing the Deployed App

Now that the deployment is complete, it’s time to test the app and confirm everything is working as expected.



Successful Test

πŸ§ͺ CI/CD Feedback in GitHub Actions

In GitHub Actions, we can visually track each step of the Build and Deploy process.

In our case, we can see that all 7 unit tests were executed successfully βœ….

This confirms that the application passed the testing phase before deployment.

❌ If any test had failed, the workflow would have been interrupted, and GitHub would have automatically notified us. This helps prevent broken code from being deployed to production.

You can view the full logs and outputs by clicking on each step within the GitHub Actions tab.




Happy Coding! πŸ₯³

Top comments (0)