Uncategorized

Startup Process Internals of Python Apps on Azure App Service for Linux – programmium


Microsoft documentation very well describes how to host a Python web app on Azure app service for Linux. In the documentation it says the essence of startup script to let the WSGI or ASGI based web server to serve the application. The startup command needs to be given in the startup command text box that is found in the “General settings” page of the app’s configuration blade.

However it is not compulsory as long as you keep the application entry points such as wsgi.py for django and application.py for flask in the right places.

This is possible since Azure app services for Linux for Python stack comes with a file called entrypoint.py which is the global entry point in /usr/local/bin directory. This file contains the logic to look for the framework specific entry points such as wsgi.py for Django inside a directory under root folder or application.py for flask under the root folder or even custom entry points which are mentioned through startup command in the portal. You can view this file in the app service’s kudu portal SSH in /usr/local/bin directory as entrypoint.py.

Additionally the service also contains a global startup file which could be found at /opt/startup/startup.py. Any commands you add in the startup textbox in the configuration blade will be added to the bottom of this file. Additionally both these default entry point and startup uses gunicorn as the web server.

So as long as you keep the above mentioned files according to your platform at the right level of the directories, if you use either Django or Flask, you could simply use the “Deployment Centre” blade of your app service, choose the repository for the continuous deployment or configure the pipeline and Azure app service will take care of the rest.

This is how the application startup process words in Azure app service for Linux on Python stack. If you keep digging you could also find msodbcsql18 driver, the Microsoft ODBC Driver for SQL Server, version 18 as well available in one of the sub directories of /opt directory. This is a myth buster and for some reason, its not really easy find documentation regarding these processes. Sometimes LLMs too are not helpful to find these information:

Happy Coding and Keep Hacking.



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *