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.