Azure App Service is trying to use eventlet worker class but the module is not installed, causing:
ModuleNotFoundError: No module named 'eventlet'
-
Ensure
requirements.txtis in the correct location:- The
requirements.txtshould be in/home/site/wwwroot/backend/or/home/site/wwwroot/ - Azure App Service automatically installs dependencies from
requirements.txtduring build
- The
-
Configure Azure App Service Startup Command:
- Go to Azure Portal → Your App Service → Configuration → General settings
- Set Startup Command to:
cd /home/site/wwwroot/backend && bash startup.sh
- Or if your app is in the root:
bash startup.sh
-
Alternative: Use Python directly with requirements installation:
pip install -r requirements.txt && gunicorn --bind=0.0.0.0:8000 --worker-class eventlet --workers=1 app:app
If you don't need WebSocket support or can use a different approach:
-
Change startup command to:
gunicorn --bind=0.0.0.0:8000 --worker-class sync --workers=4 --timeout=120 app:app
-
Note: This won't support WebSocket connections. For WebSocket support, you need
eventletorgevent.
-
Add to requirements.txt:
gevent==23.9.1 gevent-websocket==0.10.1 -
Change startup command to:
gunicorn --bind=0.0.0.0:8000 --worker-class gevent --workers=1 --timeout=120 app:app
The most common issue is that Azure isn't finding or installing requirements.txt.
-
Check file location:
- Requirements.txt should be in the deployment root or backend directory
- Azure looks for it in
/home/site/wwwroot/requirements.txtor/home/site/wwwroot/backend/requirements.txt
-
Enable Oryx build:
- Go to Azure Portal → Configuration → General settings
- Ensure "Always On" is enabled
- Check "SCM_DO_BUILD_DURING_DEPLOYMENT" is set to
true(default)
-
Manual installation in startup:
pip install -r /home/site/wwwroot/backend/requirements.txt && gunicorn --bind=0.0.0.0:8000 --worker-class eventlet --workers=1 app:app
For TopicsFlow with WebSocket support, use:
Startup Command:
cd /home/site/wwwroot/backend && pip install --no-cache-dir -r requirements.txt && gunicorn --bind=0.0.0.0:8000 --worker-class eventlet --workers=1 --timeout=120 --access-logfile - --error-logfile - app:appThis ensures:
- Dependencies are installed before starting
- Eventlet worker is used for WebSocket support
- Single worker (required for eventlet with SocketIO)
- Proper logging
After deployment, check logs to verify:
eventletis installed- Gunicorn starts successfully
- No import errors