Skip to content

About

A Flask application deployed on Microsoft Azure with an automated CI/CD pipeline using GitHub Actions, automated testing with Pytest, and production deployment through Azure App Service.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

Repository files navigation

CodeAlpha Azure CI/CD Project

A Flask web application deployed on Microsoft Azure with an automated CI/CD pipeline using GitHub Actions.

This project was developed as part of my CodeAlpha internship to gain practical experience with cloud deployment, continuous integration, continuous deployment, automated testing, and Azure App Service.

Project Overview

The application itself is intentionally simple. It provides a few API endpoints that return application and health information.

The main purpose of this project is to demonstrate how application code can be automatically tested and deployed to the cloud whenever changes are pushed to GitHub.

The deployment pipeline follows this workflow:

Developer pushes code
        |
        v
     GitHub
        |
        v
 GitHub Actions
        |
        v
 Install dependencies
        |
        v
 Run automated tests
        |
        v
 Tests pass?
    /       \
  No         Yes
  |           |
 Stop      Azure Login
              |
              v
       Azure App Service
              |
              v
       Application deployed

The deployment job only runs when the tests pass and the change is pushed to the master branch.

Features

  • Flask API
  • Automated testing with Pytest
  • GitHub Actions CI/CD pipeline
  • Automatic deployment to Azure App Service
  • Gunicorn production WSGI server
  • Azure CLI based cloud management
  • Secure Azure authentication using GitHub Secrets
  • Health check endpoint
  • Application version endpoint

API Endpoints

GET /

Returns the current application status.

Example response:

{
    "message": "Azure CI/CD Demo Application",
    "status": "running"
}

GET /health

Returns the health status of the application.

Example response:

{
    "status": "healthy"
}

GET /version

Returns the current application version.

Example response:

{
    "version": "1.0.0"
}

Live Application

The application is deployed on Microsoft Azure App Service.

Base URL:

https://codealpha-azure-cicd-rameen.azurewebsites.net

Example:

https://codealpha-azure-cicd-rameen.azurewebsites.net/health

CI/CD Pipeline

The GitHub Actions workflow is defined in:

.github/workflows/ci.yml

Whenever code is pushed to the master branch, the workflow performs the following steps:

  1. Checks out the repository.
  2. Sets up Python 3.13.
  3. Installs project dependencies.
  4. Runs the automated test suite.
  5. Authenticates with Microsoft Azure.
  6. Configures the Azure App Service for dependency installation.
  7. Deploys the application to Azure App Service.

The deployment job depends on the test job, so deployment is blocked if the tests fail.

Testing

The project uses Pytest for automated testing.

The current test suite covers:

  • Application home endpoint
  • Health endpoint
  • Version endpoint

Run the tests locally with:

python -m pytest

Current result:

3 passed

Azure Deployment

The application is hosted using:

  • Azure Resource Group
  • Azure App Service Plan
  • Azure App Service
  • Linux-based Python runtime
  • Gunicorn

The Azure resources were created and configured using Azure CLI.

The production application uses Gunicorn with the following startup command:

gunicorn --bind=0.0.0.0:8000 run:app

Project Structure

CodeAlpha_azure_cicd_project/
|
+-- .github/
|   +-- workflows/
|       +-- ci.yml
|
+-- app/
|   +-- __init__.py
|
+-- tests/
|   +-- test_app.py
|
+-- .gitignore
+-- requirements.txt
+-- run.py
+-- README.md

Tech Stack

  • Python 3.13
  • Flask
  • Pytest
  • Gunicorn
  • Git
  • GitHub
  • GitHub Actions
  • Microsoft Azure
  • Azure App Service
  • Azure CLI

Running the Project Locally

1. Clone the repository

git clone https://github.com/rameenali03/CodeAlpha_azure_cicd_project.git
cd CodeAlpha_azure_cicd_project

2. Create a virtual environment

python -m venv venv

3. Activate the virtual environment

On Windows PowerShell:

.\venv\Scripts\Activate.ps1

4. Install dependencies

pip install -r requirements.txt

5. Run the application

python run.py

The application will be available locally at:

http://127.0.0.1:5000

Project Outcome

This project provided hands-on experience with:

  • Building a basic Flask application
  • Writing automated tests
  • Managing dependencies
  • Using Git and GitHub
  • Creating GitHub Actions workflows
  • Managing Azure resources with Azure CLI
  • Deploying a Python application to Azure App Service
  • Configuring a production WSGI server with Gunicorn
  • Using GitHub Secrets for cloud authentication
  • Implementing an automated test-before-deploy workflow

The final result is a working cloud deployment where a successful code push can trigger automated testing and deployment to Azure.

Internship

Developed as part of the CodeAlpha Internship program.

About

A Flask application deployed on Microsoft Azure with an automated CI/CD pipeline using GitHub Actions, automated testing with Pytest, and production deployment through Azure App Service.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages