Reputation: 361
I am currently deploying using Python 3.9 to install the depencies and setup the azure function to also use Python 3.9
Here is the requirements file I am currently using
msrest==0.6.16
azure-core==1.6.0
azure-functions
azure-storage-blob==12.5.0
pandas
numpy
pyodbc
requests==2.23.0
snowflake-connector-python==2.4.0
azure.identity
azure.keyvault.secrets==4.1.0
azure.servicebus==0.50.3
pyarrow==3.0.0
stopit==1.1.2
The bash script to install the required dependencies during the build definition
python3.9 -m venv worker_venv
source worker_venv/bin/activate
pip3.9 install setuptools
pip3.9 install --upgrade pip
pip3.9 install -r requirements.txt
My python scripts are using the following imports
import logging
from azure.storage.blob import *
import datetime
import azure.functions as func
import json
The most helpful article I could find was https://learn.microsoft.com/en-us/azure/azure-functions/recover-python-functions?tabs=coretools
As a work-around I tried the remote build option using command: func azure functionapp publish . Interestingly enough when I use that command the error disappears during execution and the function works as expected. I would like to enable the automatic build and deploy process again which did work until I needed to include the pyarrow library.
Any suggestions on what I am doing incorrectly?
Upvotes: 2
Views: 1340
Reputation: 361
I was able to download the content which was generated by the remote build. I then discovered it has a .python_packages folder. I now updated my install dependencies bash script to the example below which mimics how the remote build creates the the .python_packages .In essence I am copying the downloaded packages from worker_venv/lib64/python3.9/site-packages to .python_packages/lib/site-packages. My function is now executing without any errors anymore.
python3.9 -m venv worker_venv
source worker_venv/bin/activate
pip3.9 install setuptools
pip3.9 install --upgrade pip
pip3.9 install -r requirements.txt
mkdir .python_packages
cd .python_packages
mkdir lib
cd lib
mv ../../worker_venv/lib64/python3.9/site-packages .
Upvotes: 2