How to Deploy a Dockerized API to Azure App Service Using GitHub Actions or Azure DevOps

How to Deploy a Dockerized API to Azure App Service Using GitHub Actions or Azure DevOps

Objective

To demonstrate how to containerize an API (e.g., .NET, Node.js, Python), deploy it to Azure App Services using Docker, and set up an automated CI/CD workflow with GitHub Actions or Azure DevOps. We’ll also cover local development and testing.


Prerequisites

  • Azure account with App Service plan (Linux).
  • Docker installed on your local machine.
  • A working API project.
  • Azure CLI or Docker CLI authenticated.
  • GitHub or Azure DevOps repository.


Step 1: Containerize Your API Locally

Sample Dockerfile (.NET 8 example)

Article content

Build and run locally

Article content

Step 2: Create an Azure App Service for Containers

Article content

Step 3: Push Your Docker Image

You can use Docker Hub or Azure Container Registry (ACR).

Docker Hub

Article content

ACR (optional)

Article content

Step 4: Configure App Service to Use Your Container

Article content

Step 5: Setup CI/CD with GitHub Actions

Sample GitHub Workflow (.github/workflows/deploy.yml)

Article content

Step 6: Local Development Tips

Debug with Docker locally

  • Use docker-compose if you have dependencies (e.g., databases).
  • Mount local volume for hot reload (optional).
  • Use launchSettings.json and environment variables to simulate production.

Example for VS Code launch.json

Article content

Summary

1.Dockerize the API

2.Deploy App Service on Linux

3.Push Docker image

4.Connect App Service to container

5.Set up GitHub Actions for CI/CD

6.Debug locally with Docker

References

To view or add a comment, sign in

More articles by Luis Gabriel Ahumada

Insights from the community

Others also viewed

Explore topics