:( Application Error - Python NLP Flask App

msds498 0 Reputation points
2023-02-16T02:19:25.79+00:00

I am creating an NLP Flask app with Python and when I run the app in my IDE, everything works great and my app functions as expected.

I have an App Service in my Azure account that I am using for CI/CD deployment. The deployment is marked successful, however when I go to the app URL, I get the :( application error warning messing. I am very confused as to why this is happening.

Details:

Directory Structure:

MSDS498_ChatBot_FlaskApp/
├── app.py
├── img_etl.py
├── Makefile
├── README.md
├── requirements.txt
├── static
│   ├── brucechou1983_CheXNet_Keras_0.3.0_weights.h5
│   ├── Encoder_Decoder_global_attention.h5
│   ├── tokenizer.pkl
│   └── uploads
│       └── __init__.py
└── templates
    ├── acknowledgement.html
    ├── gen_text.html
    ├── home.html
    ├── output.html
    ├── upload.html
    └── upload_img_rest.html

  • Main Flask app is called app in the app.py file. This is in the root folder of my directory which should get uploaded to the virtual machine. From the Microsoft documentation here the naming conventions are correct and App Service should find my app.py file with no issues and launch the gunicorn WSGI server without issues... First 20 lines from the app.py file shown below.
"""Main Flask App for ChatBot."""
from fileinput import filename
import os
from flask import Flask, render_template, request, jsonify, send_from_directory
from werkzeug.utils import secure_filename
from img_etl import make_prediction

# Define upload folder path:
UPLOAD_FOLDER = os.path.join("static",'uploads')
# Define allowed files:
ALLOWED_EXTENSIONS = {'txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'}

app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

@app.route("/")
def welcome():
    """Chatbot API Home Page."""
    return render_template("home.html")

I am unable to verify if the files are being written to the virtual machine. I am unable to SSH into the VM hosting my web app since it doesn't appear to be running.

I know there are some dependencies that are required outside of the requirements.txt file and I have added them to the Github Actions CI/CD build file.... Ex:

      - name: Create and start virtual environment
        run: |
          python -m venv venv
          source venv/bin/activate
      - name: Make virtual environment compatible
        run: |
          sudo apt-get update
          sudo apt-get install libgl1
      - name: Install dependencies
        run: pip install -r requirements.txt

Since the build step is complete, I am assuming that the VM environment should have all dependencies required to run these files as done similarly in my IDE when I launch my own virtual environment.

It doesn't appear my files are being transferred to the VM so I tried to transfer via FTP using FileZilla with no luck.

Not really sure where to go from here... I was able to successfully launch the web app with the same App Service resource before adding some NLP functionality. I can go back and find the files / dependencies causing the issues, but that still won't solve the issues I am having.

Please advise.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,518 questions
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,111 questions
{count} votes

1 answer

Sort by: Most helpful
  1. VenkateshDodda-MSFT 24,241 Reputation points Microsoft Employee
    2023-02-21T05:40:00.73+00:00

    @msds498 Thank you for reaching out to Microsoft Q&A, apologize for any inconvenience caused on this.

    • I would suggest you enable diagnostic logging or run the webapp down detector under Diagnose and Solve Problems of your webapp to identity the cause.
    • If you want to check whether the files were deployed in app service or not you can ssh into the app service and this can be done in multiple methods. Refer to this documentation on how to ssh to a linux container on Azure app service.

    For more details you can refer to this blogpost on how deploy flask application on linux app service.

    Feel free to reach back to me if you have any further questions on this.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.