How to deploy a Python Flask web app with lots of packages in requirements.txt

Buck, Patrick 0 Reputation points
2024-06-12T14:06:29.6233333+00:00

I have a Python / Flask application that deploys to Azure without any errors in the logs. Unfortunately, the app does not appear after deployment. I only see the default app with UI that says 'Your web app is running and waiting for your content'.

I'm deploying the app using VS Code. I already went through the Troubleshooting guide but I'm not missing anything.

What seems to be causing the issue is that my app has a long list of packages in requirements.txt. I verified this causes a problem by testing the hypothesis using the 'msdocs-python-flask-webapp-quickstart' app.

I created a clean deployment of the test app and it deployed with no errors and the app appeared.

I then modified the test app by adding a list of imports into app.py and I added lines into requirements.txt to match all the packages I need for my own app.

When I then made a new clean deployment of the modified test app, it exhibited the same issue as my own app.

Simply adding a longer list of python packages causes something to go wrong in the deployment. It looks like the app files are not getting placed where they should be. The result is that the app UI does not show even though the deployment does not report any errors.

I noticed in the deployment logs that it takes a while for pip install and then compression to run. But the app files (and app UI) still don't appear after that process is done.

Any suggestions on how to deploy a Python web app that has requires a lot of packages?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,234 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Buck, Patrick 0 Reputation points
    2024-06-13T19:11:25.58+00:00

    I discovered that if I set the environment variable WEBSITES_CONTAINER_START_TIME_LIMIT to a large enough value, the web app was able to start properly. The start needed to happen after all of the python packages got installed and after the compression step. It was taking about half an hour for that process to finish


  2. ajkuma 23,911 Reputation points Microsoft Employee
    2024-06-17T19:59:51.4366667+00:00

    Scenario: Python/Flask application deployment to Azure App Service using VS Code with app having long list of packages in requirements.txt.

    Issue: The application deploys without any errors in the logs, but the app does not appear after deployment. Instead, the default app with UI that says ‘Your web app is running and waiting for your content’.

    Posting the answer/solution shared by @Buck, Patrick .

    Resolution:

    By default, if your container does not respond after 230 seconds, it will time out. (This time out can be increased by with the WEBSITES_CONTAINER_START_TIME_LIMIT app setting.) (up to a maximum of 1800).

    Ref: Troubleshooting ‘Container didnt respond to HTTP pings on port, failing site start’


     If the answer helped (pointed, you in the right direction) > please click Accept Answer - it will benefit community members to find the answers quickly. 

    0 comments No comments