I'm pushing a Flask web app to azure from a local git repo. The app has a .deployment file that points to scripts/deploy.sh that runs an npm run build action and copies the generated build to the app's static folder.
The azure docs suggest that placing requirements.txt at the top of the repo will automatically run pip install -r requirements.txt. I can't see any evidence that this command is running and I wonder if the custom deployment script overrides it. If I explicitly call this command in the file, I see:
scripts/deploy.sh: line 20: pip: command not found
This seems to be because the container built at deployment has its own virtual environment. How do I convince the deployment process to run pip install in the virtual environment?
Application log after build and launch:
2024-03-27T04:38:07.838468802Z: [INFO] Updated PYTHONPATH to '/opt/startup/app_logs:/tmp/8dc4df81676606a/antenv/lib/python3.10/site-packages'
2024-03-27T04:38:07.914410500Z: [ERROR] Traceback (most recent call last):
2024-03-27T04:38:07.915612203Z: [ERROR] File "/tmp/8dc4df81676606a/backend/app.py", line 6, in <module>
2024-03-27T04:38:07.916790406Z: [ERROR] from dotenv import load_dotenv
2024-03-27T04:38:07.917807108Z: [ERROR] ModuleNotFoundError: No module named 'dotenv'Ending Log Tail of existing logs ---Starting Live Log Stream ---
EDIT: specifying python3-dotenv instead of python-dotenv did not resolve the issue. Neither did setting SCM_DO_BUILD_DURING_DEPLOYMENT.
Activate the virtual environment by adding below commands in the deployment script
deploy.sh:I have created a flask application and used below code:
Folder Structure:
App Service Logs:
Response: