azure-functions-python-worker
azure-functions-python-worker copied to clipboard
Help needed: built dependencies fail in Azure Function deployment from AzureDevOps
My team has created an Azure function and successfully deployed it using VS Code.
However, we want to set it up to build and deploy through Azure DevOps, in order to take advantage of the many benefits offered.
Unfortunately, no matter how we set up the build and deploy process(es) in Azure DevOps, we run into issues with compiled dependencies not working correctly.
Our dependencies include azure-storage-blob
, azure-storage-filelake
, and psycopg2
, both of which seem to need some building during install.
We created the azure-pipelines.yml
just like it's recommended for python3.7.
We also set up a Release pipeline with the Azure Functions 1.*
task.
(We've also tries deploying directly from the Build pipeline)
But every time we try something new, we still get errors whenever we trigger the function. In this case, the run fails when trying to import azure-storage
Traceback:
Result: Failure Exception: ModuleNotFoundError: No module named '_cffi_backend'. Troubleshooting Guide: https://aka.ms/functions-modulenotfound Stack: File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/dispatcher.py", line 262, in _handle__function_load_request func = loader.load_function( File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 34, in call raise extend_exception_message(e, message) File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 32, in call return func(*args, **kwargs) File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/loader.py", line 76, in load_function mod = importlib.import_module(fullmodname) File "/usr/local/lib/python3.8/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/home/site/wwwroot/GTreasurySaver/init.py", line 6, in
from .adls import ADLSStorageService File "/home/site/wwwroot/GTreasurySaver/adls.py", line 3, in from azure.storage.filedatalake import DataLakeServiceClient File "/home/site/wwwroot/.python_packages/lib/site-packages/azure/storage/filedatalake/init.py", line 7, in from ._download import StorageStreamDownloader File "/home/site/wwwroot/.python_packages/lib/site-packages/azure/storage/filedatalake/_download.py", line 7, in from ._models import FileProperties File "/home/site/wwwroot/.python_packages/lib/site-packages/azure/storage/filedatalake/_models.py", line 11, in from azure.storage.blob import LeaseProperties as BlobLeaseProperties File "/home/site/wwwroot/.python_packages/lib/site-packages/azure/storage/blob/init.py", line 11, in from ._blob_client import BlobClient File "/home/site/wwwroot/.python_packages/lib/site-packages/azure/storage/blob/_blob_client.py", line 24, in from ._shared.encryption import generate_blob_encryption_data File "/home/site/wwwroot/.python_packages/lib/site-packages/azure/storage/blob/_shared/encryption.py", line 19, in from cryptography.hazmat.primitives.padding import PKCS7 File "/home/site/wwwroot/.python_packages/lib/site-packages/cryptography/hazmat/primitives/padding.py", line 13, in from cryptography.hazmat.bindings._padding import lib
We see the dependencies being built and installed in the build pipeline, and they're there when we download the artifact. But it seems it's not built for the Azure Function environment, or we need to have a flag set for the Function environment to build the dependencies afresh.
I'm sure something like this exists, but we haven't been able to find it yet. After all, as I said at the beginning, we can deploy it by using VS Code.
I'd love some help figureing out how to get it to work through DevOps.
Investigative information
Please provide the following:
- Timestamp:
- Function App name: mna-nonprod-innov-gtreasury
- Function name(s) (as appropriate): GTreasurySaver
- Core Tools version:
Contents of the requirements.txt file:
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile requirements.in
#
attrs==19.3.0 # via environ-config
azure-core==1.6.0 # via azure-storage-blob, azure-storage-file-datalake
azure-functions==1.2.1 # via -r requirements.in
azure-storage-blob==12.3.1 # via -r requirements.in, azure-storage-file-datalake
azure-storage-file-datalake==12.0.1 # via -r requirements.in
certifi==2020.4.5.1 # via msrest, requests
cffi==1.14.0 # via cryptography
chardet==3.0.4 # via requests
cryptography==2.9.2 # via azure-storage-blob
environ-config==20.1.0 # via -r requirements.in
idna==2.9 # via requests
isodate==0.6.0 # via msrest
msrest==0.6.14 # via azure-storage-blob, azure-storage-file-datalake
oauthlib==3.1.0 # via requests-oauthlib
psycopg2==2.8.5 # via -r requirements.in
pycparser==2.20 # via cffi
requests-oauthlib==1.3.0 # via msrest
requests==2.23.0 # via -r requirements.in, azure-core, msrest, requests-oauthlib
six==1.15.0 # via azure-core, cryptography, isodate
sqlalchemy==1.3.17 # via -r requirements.in
urllib3==1.25.9 # via requests
wheel==0.34.2 # via -r requirements.in
I could really use some help.
Hi @Chris-May, thanks for your email.
Seems like your function app is running on Python 3.8, could you confirm if the pipeline is using Python 3.8 instead of Python 3.7?
Hey @Hazhzeng! Thank you so much for taking time to look into this.
The pipeline was using 3.7, but I just changed it, and got the same error.
@Hazhzeng @Chris-May is this issue still open? It looks very similar to my own issue https://github.com/Azure/azure-functions-python-worker/issues/827 and this other new issue that was logged https://github.com/Azure/azure-functions-python-worker/issues/831.
Did you find a workaround @Chris-May ?
Hi @Chris-May , Can we know if this is still persisting, we apologize for not following up frequently.