From 91406b4be86dc4c0aa2473dbc9d734017269f74d Mon Sep 17 00:00:00 2001 From: Samuel Akinwumi Adeniji <122861206+Tech-sam-90@users.noreply.github.com> Date: Tue, 25 Nov 2025 16:01:04 +0200 Subject: [PATCH 1/5] Update print statement from --- app.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 3ae0782..7000cb7 100644 --- a/app.py +++ b/app.py @@ -41,7 +41,7 @@ # DB connection try: - conn = psycopg2.connect(DATABASE_URL, sslmode='require') + conn = psycopg2.connect(DATABASE_URL, sslmode='verify-full') cursor = conn.cursor() logging.info("Database connection successful.") except Exception as e: @@ -812,3 +812,4 @@ def get_upload_statistics(): logging.warning("One or more critical environment variables are not set. The application might not function correctly.") app.run(host="0.0.0.0", port=10000) + From 9bc57e638ac376025842a1ac60371032a6b1bfd8 Mon Sep 17 00:00:00 2001 From: Samuel Akinwumi Adeniji <122861206+Tech-sam-90@users.noreply.github.com> Date: Tue, 25 Nov 2025 19:33:38 +0200 Subject: [PATCH 2/5] Add or update the Azure App Service build and deployment workflow config --- .github/workflows/email-veri_ai4lassa-app.yml | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/email-veri_ai4lassa-app.yml diff --git a/.github/workflows/email-veri_ai4lassa-app.yml b/.github/workflows/email-veri_ai4lassa-app.yml new file mode 100644 index 0000000..0223b94 --- /dev/null +++ b/.github/workflows/email-veri_ai4lassa-app.yml @@ -0,0 +1,76 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions +# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions + +name: Build and deploy Python app to Azure Web App - ai4lassa-app + +on: + push: + branches: + - email-veri + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read #This is required for actions/checkout + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python version + uses: actions/setup-python@v5 + with: + python-version: '3.13' + + # 🛠️ Local Build Section (Optional) + # The following section in your workflow is designed to catch build issues early on the client side, before deployment. This can be helpful for debugging and validation. However, if this step significantly increases deployment time and early detection is not critical for your workflow, you may remove this section to streamline the deployment process. + - name: Create and Start virtual environment and Install dependencies + run: | + python -m venv antenv + source antenv/bin/activate + pip install -r requirements.txt + + # By default, when you enable GitHub CI/CD integration through the Azure portal, the platform automatically sets the SCM_DO_BUILD_DURING_DEPLOYMENT application setting to true. This triggers the use of Oryx, a build engine that handles application compilation and dependency installation (e.g., pip install) directly on the platform during deployment. Hence, we exclude the antenv virtual environment directory from the deployment artifact to reduce the payload size. + - name: Upload artifact for deployment jobs + uses: actions/upload-artifact@v4 + with: + name: python-app + path: | + . + !antenv/ + + # 🚫 Opting Out of Oryx Build + # If you prefer to disable the Oryx build process during deployment, follow these steps: + # 1. Remove the SCM_DO_BUILD_DURING_DEPLOYMENT app setting from your Azure App Service Environment variables. + # 2. Refer to sample workflows for alternative deployment strategies: https://github.com/Azure/actions-workflow-samples/tree/master/AppService + + + deploy: + runs-on: ubuntu-latest + needs: build + permissions: + id-token: write #This is required for requesting the JWT + contents: read #This is required for actions/checkout + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v4 + with: + name: python-app + + - name: Login to Azure + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_FB308BD661244A408B23B0BE4573151E }} + tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_DE43D645B2E741AAABF63A599F0885B6 }} + subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_3D58B448BDAD4C84B9A9204AB5FB415E }} + + - name: 'Deploy to Azure Web App' + uses: azure/webapps-deploy@v3 + id: deploy-to-webapp + with: + app-name: 'ai4lassa-app' + slot-name: 'Production' + \ No newline at end of file From 92d8314cf660f4f0d36d75fbac807441d552b768 Mon Sep 17 00:00:00 2001 From: Samuel Akinwumi Adeniji <122861206+Tech-sam-90@users.noreply.github.com> Date: Tue, 25 Nov 2025 19:54:02 +0200 Subject: [PATCH 3/5] Update and rename app.py to application.py --- app.py => application.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app.py => application.py (100%) diff --git a/app.py b/application.py similarity index 100% rename from app.py rename to application.py From 54314a4065fcab62da80af9bb38abf3b763eba8d Mon Sep 17 00:00:00 2001 From: Samuel Akinwumi Adeniji <122861206+Tech-sam-90@users.noreply.github.com> Date: Tue, 25 Nov 2025 20:42:07 +0200 Subject: [PATCH 4/5] Update the Database_url --- application.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application.py b/application.py index 7000cb7..c1ef65b 100644 --- a/application.py +++ b/application.py @@ -26,7 +26,7 @@ # ========== Configuration ========== # Environment variables -DATABASE_URL = os.environ.get("DATABASE_URL", "your_local_fallback") +DATABASE_URL = os.environ.get("DATABASE_URL") SECRET_KEY = os.environ.get("SECRET_KEY", "change_this_key") SUPERADMIN_SECRET_KEY = os.environ.get("SUPERADMIN_SECRET_KEY", "your_super_secret_key") JWT_ALGORITHM = "HS256" @@ -813,3 +813,4 @@ def get_upload_statistics(): app.run(host="0.0.0.0", port=10000) + From dd0086a226af19d1a3ec6e4c1254f0261cba5784 Mon Sep 17 00:00:00 2001 From: Samuel Akinwumi Adeniji <122861206+Tech-sam-90@users.noreply.github.com> Date: Tue, 25 Nov 2025 21:01:45 +0200 Subject: [PATCH 5/5] Updating the sssl mode of the database connection --- application.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application.py b/application.py index c1ef65b..3bc0e4b 100644 --- a/application.py +++ b/application.py @@ -41,7 +41,7 @@ # DB connection try: - conn = psycopg2.connect(DATABASE_URL, sslmode='verify-full') + conn = psycopg2.connect(DATABASE_URL, sslmode='require') cursor = conn.cursor() logging.info("Database connection successful.") except Exception as e: @@ -814,3 +814,4 @@ def get_upload_statistics(): +