I have some question about app service run sequence for python.

woosoek jang 20 Reputation points
2024-04-10T22:01:12.09+00:00

Hi, I have some question about app service run sequence. First of all, I build up my first app with quick start guide(https://learn.microsoft.com/en-us/azure/app-service/quickstart-python?tabs=flask%2Cwindows%2Cazure-cli%2Cazure-cli-deploy%2Cdeploy-instructions-azportal%2Cterminal-bash%2Cdeploy-instructions-zip-azcli). But, I cannot understand that what command is executed on app during run sequence, and how I can configure that. I guess that App service has expose wsgi application to some port, but what port? 5000? 8080? And if I want to execute some command before deploy, how can I do that? Please, take some guide for me. Thank you.

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

Accepted answer
  1. ajkuma 26,141 Reputation points Microsoft Employee
    2024-04-12T10:28:18.8033333+00:00

    @woosoek jang , Based on my understanding of your question description,  I'm highlighting the App Service on Linux container (startup process) | it runs the following steps outline below. Sorry for the long post.

    App Service uses the Gunicorn web server by default, which must be able to find your app object or wsgi.py folder. If needed, you can always customize the startup command.

    1. Use a custom startup command, if provided. In Azure portal: select the app's Configuration page, then select General settings. Add Startup Command
    2. Check for the existence of a Django app, and launch Gunicorn for it if detected  or check for the existence of a Flask app, and launch Gunicorn for it if detected.
    3. If no other app is found, start a default app that's built into the container.

     

    In the App Service, app settings function as variables transmitted as environment variables to the application code. For Linux applications and custom containers, App Service delivers app settings to the container by utilizing the --env flag to establish the environment variable within the container. Regardless of the scenario, these settings are introduced into your application environment during startup. Any modifications to app settings, whether they involve addition, removal, or editing, prompt an app restart in the App Service.

     

    Just to highlight, if you are leveraging App Service custom container, App Service has no control about which port your container listens on.

    In this case, you need to set the WEBSITES_PORT app setting to the port number, and App Service forwards requests to that port in the container. The WEBSITES_PORT app setting does not have any effect within the container, and you can’t access it as an environment variable within the container.

    Kindly checkout this doc section Configure a Linux Python app for Azure App Service | Container characteristics for more details.

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

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

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.