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.
8,935 questions
{count} votes

1 answer

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


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.