pythonazureazure-webapps

Python app deployment to Azure web app from pipeline not including requirement packages


I have a Python flask app that I want to deploy to an Azure Web App.

For some reason the venv that gets created during the build is not keeping the packages that get installed and I don't understand why. As an example, the requirements.txt has openai==1.12.0 in it.
The build job prints Successfully installed [...] openai-1.12.0 [...]. That sounds like it should be fine.

Then in the Azure shell of the web app after the deploy is successful I run pip list(with the antenv virtual enviroment active) to see what is installed and get a list with no openai. If I list the contents of the venv folder it contains all packages that I wanted installed...

This is the yaml for the build job:

          - script: |
              sudo apt-get install python3.11-dev portaudio19-dev
              ls
              python -m venv antenv
              source antenv/bin/activate
              python -m pip install --upgrade pip
              pip install -r ./requirements.txt
            workingDirectory: "$(projectRoot)"
            displayName: "Install requirements"

I also tried to change the pip install line to
pip install --target="./.python_packages/lib/site-packages" -r ./requirements.txt
with no luck, the packages are in that folder but not in use by the venv.
Am I doing anything obviously wrong? Any tips?

Edit: This is my pip list out put after the pip install steps:


h11                    0.14.0
httpcore               1.0.3
httpx                  0.26.0
idna                   3.6
isodate                0.6.1
itsdangerous           2.1.2
Jinja2                 3.1.3
langdetect             1.0.9
MarkupSafe             2.1.5
msrest                 0.7.1
numpy                  1.26.4
oauthlib               3.2.2
openai                 1.12.0
openpyxl               3.1.2
pandas                 2.2.0
pip                    24.0
PyAudio                0.2.14
pydantic               2.6.1
pydantic_core          2.16.2
python-dateutil        2.8.2
python-dotenv          1.0.1
pytz                   2024.1
requests               2.31.0
requests-oauthlib      1.4.0
setuptools             65.5.0
six                    1.16.0
sniffio                1.3.0
SpeechRecognition      3.10.1
tqdm                   4.66.2
typing_extensions      4.9.0
tzdata                 2024.1
urllib3                2.2.0
waitress               3.0.0
Werkzeug               3.0.1
WTForms                3.1.2

And this is the result from running pip list in the venv in the Azure SSH shell:

Package              Version
-------------------- -------
appsvc-code-profiler 1.0.0
blinker              1.7.0
click                8.1.7
debugpy              1.8.1
distlib              0.3.8
filelock             3.13.1
Flask                3.0.2
gunicorn             21.2.0
itsdangerous         2.1.2
Jinja2               3.1.3
markdown-it-py       3.0.0
MarkupSafe           2.1.5
mdurl                0.1.2
objprint             0.2.3
orjson               3.8.10
packaging            24.0
pip                  24.0
platformdirs         4.2.0
psutil               5.9.8
Pygments             2.17.2
rich                 13.7.1
setuptools           69.1.0
subprocess32         3.5.4
virtualenv           20.25.1
vizplugins           0.1.3
viztracer            0.15.6
Werkzeug             3.0.1
wheel                0.42.0

Solution

  • Turns out it just looks like packages are missing in the Azure ssh shell. My problem was that my entry point was not found by Azure and I had to specify it to get my app running. The actual application is running with the correct packages installed even though pip list looks like it does not have all packages.