Docker logs are OK but Didn't respond to HTTP pings on port: 8000, failing site start

Cyril FRANCOIS 0 Reputation points
2024-04-05T11:49:14.28+00:00

I want to run a NiceGui application integrated into a FastAPI one.
It works fine on local.

I tested to deploy the application to Azure Web App, but it failed. I directly deploy my project without using a container.

I do not know or understand where I failed. It seems the application works fine on the port 8000, but the container does not respond to this port. How can I manage this? Is it something deep in the way Azure Web App works that I did not understand?

See the docker logs:

2024-04-05T09:32:26.605732515Z    _____                               
2024-04-05T09:32:26.605761416Z   /  _  \ __________ _________   ____  
2024-04-05T09:32:26.605765416Z  /  /_\  \\___   /  |  \_  __ \_/ __ \ 
2024-04-05T09:32:26.605776216Z /    |    \/    /|  |  /|  | \/\  ___/ 
2024-04-05T09:32:26.605779616Z \____|__  /_____ \____/ |__|    \___  >
2024-04-05T09:32:26.605782817Z         \/      \/                  \/ 
2024-04-05T09:32:26.605785717Z A P P   S E R V I C E   O N   L I N U X
2024-04-05T09:32:26.605788517Z 
2024-04-05T09:32:26.605791117Z Documentation: http://aka.ms/webapp-linux
2024-04-05T09:32:26.605793917Z Python 3.11.7
2024-04-05T09:32:26.605796817Z Note: Any data outside '/home' is not persisted
2024-04-05T09:32:28.779439799Z Starting OpenBSD Secure Shell server: sshd.
2024-04-05T09:32:28.929754495Z Site's appCommandLine: startup.sh
2024-04-05T09:32:28.938713693Z Launching oryx with: create-script -appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite -userStartupCommand 'startup.sh'
2024-04-05T09:32:29.079237264Z Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it...
2024-04-05T09:32:29.096727145Z Build Operation ID: 90d472ee88195075
2024-04-05T09:32:29.117197126Z Output is compressed. Extracting it...
2024-04-05T09:32:29.117222527Z Extracting '/home/site/wwwroot/output.tar.gz' to directory '/tmp/8dc55506651b188'...
2024-04-05T09:32:29.117242227Z Oryx Version: 0.2.20240127.1, Commit: 4b7f2dffcc69c214f9806d67a85ec8926e2393e1, ReleaseTagName: 20240127.1
2024-04-05T09:33:20.384731110Z App path is set to '/tmp/8dc55506651b188'
2024-04-05T09:33:20.398345417Z Writing output script to '/opt/startup/startup.sh'
2024-04-05T09:33:20.541386995Z Using packages from virtual environment antenv located at /tmp/8dc55506651b188/antenv.
2024-04-05T09:33:20.541422896Z Updated PYTHONPATH to '/opt/startup/app_logs:/tmp/8dc55506651b188/antenv/lib/python3.11/site-packages'
2024-04-05T09:33:21.595315214Z INFO:     Will watch for changes in these directories: ['/tmp/8dc55506651b188']
2024-04-05T09:33:21.602960942Z INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
2024-04-05T09:33:21.603519459Z INFO:     Started reloader process [77] using WatchFiles
2024-04-05T09:33:50.794990930Z INFO:     Started server process [79]
2024-04-05T09:33:50.802446930Z INFO:     Waiting for application startup.
2024-04-05T09:33:50.803978471Z INFO:     Application startup complete.

And from log:

2024-04-05T09:32:23.326Z INFO  - 3.11_20240207.3.tuxprod Pulling from appsvc/python
2024-04-05T09:32:23.328Z INFO  -  Digest: sha256:6d9dcd89738bc68a6ee4424f05a51d4976414551019f521174429503141193a8
2024-04-05T09:32:23.330Z INFO  -  Status: Image is up to date for 10.1.0.4:13209/appsvc/python:3.11_20240207.3.tuxprod
2024-04-05T09:32:23.369Z INFO  - Pull Image successful, Time taken: 0 Seconds
2024-04-05T09:32:25.295Z INFO  - Starting container for site
2024-04-05T09:32:25.297Z INFO  - docker run -d --expose=8000 --name perspectiva_0_99493a7b -e WEBSITE_USE_DIAGNOSTIC_SERVER=false -e WEBSITE_SITE_NAME=perspectiva -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=perspectiva.azurewebsites.net -e WEBSITE_INSTANCE_ID=3b4e685699d78865c322a499b1ab46e96b4051fab86d1c12fbf918cde1362da3 -e HTTP_LOGGING_ENABLED=1 appsvc/python:3.11_20240207.3.tuxprod startup.sh
2024-04-05T09:32:27.924Z INFO  - Initiating warmup request to container perspectiva_0_99493a7b for site perspectiva
2024-04-05T09:33:02.591Z INFO  - Waiting for response to warmup request for container perspectiva_0_99493a7b. Elapsed time = 34.6666692 sec
2024-04-05T09:33:19.592Z INFO  - Waiting for response to warmup request for container perspectiva_0_99493a7b. Elapsed time = 51.6679531 sec
2024-04-05T09:33:37.532Z INFO  - Waiting for response to warmup request for container perspectiva_0_99493a7b. Elapsed time = 69.6078467 sec
2024-04-05T09:33:53.870Z INFO  - Waiting for response to warmup request for container perspectiva_0_99493a7b. Elapsed time = 85.9460269 sec
2024-04-05T09:34:10.846Z INFO  - Waiting for response to warmup request for container perspectiva_0_99493a7b. Elapsed time = 102.9215846 sec
.....
idem
.....
2024-04-05T09:36:18.245Z ERROR - Container perspectiva_0_99493a7b for site perspectiva did not start within expected time limit. Elapsed time = 230.3212394 sec
2024-04-05T09:36:18.280Z ERROR - Container perspectiva_0_99493a7b didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2024-04-05T09:36:18.318Z INFO  - Stopping site perspectiva because it failed during startup.

See the config file:

az webapp config set --resource-group $RESOURCEGROUP --name $SITENAME --startup-file startup.sh  --settings WEBSITES_PORT=8000

And the command uvicorn:

uvicorn src.main:app --reload --log-level debug --port 8000

Thanks a lot.

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

2 answers

Sort by: Most helpful
  1. Achraf Ben Alaya 1,056 Reputation points MVP
    2024-04-07T10:53:53.8433333+00:00

    HI ,

    you may want to :

    1- Use the EXPOSE instruction in your Dockerfile to expose port 8000.

    2-Use the WEBSITES_PORT app setting with a value of "8000" to expose that port.
    3-increase the amount of time in seconds of the container using : WEBSITES_CONTAINER_START_TIME_LIMIT

    Default Value = 230 Sec.

    Max Value= 1800 Sec

    https://learn.microsoft.com/en-us/azure/app-service/reference-app-settings?wt.mc_id=MVP_328341&tabs=kudu%2Cdotnet

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.

    0 comments No comments

  2. VenkateshDodda-MSFT 20,696 Reputation points Microsoft Employee
    2024-04-08T08:09:00.4733333+00:00

    @Cyril FRANCOIS Thank you for posting your question in Microsoft Q&A, apologize for any inconvenience caused on this.

    Based on the above shared information, I have reviewed the backend logs of the app service "perspectiva" and able to see the app is up and running.

    2024-04-05T09:36:18.318Z INFO - Stopping site perspectiva because it failed during startup.

    And also looking at the above logs it is looks the site is not able to start because of the start-up failure.

    As suggested by Achraf Ben Alaya please do increase the container start time up adding the application setting WEBSITES_CONTAINER_START_TIME_LIMIT value to 1800.

    If you are still facing issue, I would suggest reviewing your app service application logs by enabling application logs and also troubleshoot the app service using HTTP Server Errors detector under Diagnose and solve problems of app service.

    Hope this helps, let me know if you have any further questions on this.

    0 comments No comments

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.