App Service fails to start when startup command is given

Maxim Joyal 15 Reputation points
2023-02-10T09:11:57.24+00:00

Python version 3.8

I am trying to start a python app service using configuration -> general setting -> startup command.

The startup command job is to install python modules and runs the python app

"pip install -r requirements.txt && python -m uvicorn app:app --host 0.0.0.0 --port 80"

And the requirements.txt and app.py is present in root directory itself i.e., /home/site/wwwroot/

But the issue is whenever I give the startup command the app service container fails to start and if startup command is not given then the container will run normally without any error but the app will not run like this as it's dependencies are not present & it's a fastapi app hence using the startup command.

The app service config "WEBSITES_CONTAINER_START_TIME_LIMIT" is set to 600s i.e., 10 min, still the app service container does not start and I get the below error

2023-02-10T08:07:10.191Z INFO  - Starting container for site

2023-02-10T08:07:10.192Z INFO  - docker run -d --expose=8000 --name 
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,427 questions
{count} votes

2 answers

Sort by: Most helpful
  1. ajkuma 24,971 Reputation points Microsoft Employee
    2023-02-14T12:06:54.2666667+00:00

    @Maxim Joyal ,

    Firstly, just to highlight, App Service uses the Gunicorn web server by default. The Apps are run using the Gunicorn WSGI HTTP Server.

    Are you leveraging a blessed image or custom container?
    Do the webapp work fine as expected locally?

    • You may try executing the command pip install -r requirements.txt separately in the App Service container to see if there are any errors or issues with the modules.
    • I understand you have mentioned that the requirements.txt file is in root directory. Please ensure that all the modules are listed correctly and are compatible with the version of python that is being used in the app service container.
    • In your startup command, identify the WSGI callable.
         `python -m uvicorn application:app --host 0.0.0.0`  
      

    (or example, the following command starts the uvicorn server, assuming that the WSGI callable is named app and is found in application.py)

     

    If the issue still persist, review Access diagnostic logs and deployment logs to fetch more info ( as outlined in this doc)

    Additional info:

    0 comments No comments

  2. Oladapo Daniel 0 Reputation points
    2023-06-02T10:39:09.6366667+00:00

    Have you been able to resolve this, i am currently experiencing the same issue.

    Whenever i include my commands at command startup, the site fails to start..User's image

    User's image