-1

I have a created a local azure linux function and tested succesfully with func start. After testing Azure Devops Pipe Line promote it to the Azure (Linux) Function. The deployment seems to be in order.

enter image description here

Looking in the monitoring during the testing of the Azure (Linux) function it returns the following error:

Result: Failure Exception: ModuleNotFoundError: No module named 'pyodbc'. Troubleshooting Guide: https://aka.ms/functions-modulenotfound Stack: File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 305, in _handle__function_load_request func = loader.load_function( File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 42, in call raise extend_exception_message(e, message) File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 40, in call return func(*args, **kwargs) File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/loader.py", line 85, in load_function mod = importlib.import_module(fullmodname) File "/usr/local/lib/python3.9/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/home/site/wwwroot/get_nji_metadata/init.py", line 3, in from .Metadata import MetaData File "/home/site/wwwroot/get_nji_metadata/Metadata.py", line 2, in import pyodbc

Requirements.txt

astroid==2.4.2
azure-functions==1.2.1
certifi==2020.6.20
chardet==3.0.4
colorama==0.4.3
idna==2.9
isort==4.3.21
lazy-object-proxy==1.4.3
mccabe==0.6.1
pylint==2.5.3
pyodbc==4.0.30
requests==2.24.0
six==1.15.0
toml==0.10.1
urllib3==1.25.9
wrapt==1.12.1

Question

  1. Is there a way to solve this issue in the "Linux variant" . I already looked at the Linux Python Azure Function APP - pyodbc module not found despite being in requirements.txt and other modules working fine but don't understand the solution of this guy. Also looked at the Microsoft documentation.
  2. Do i solve this issue on the "Windows variant" for Azure Functions ?

Please help me?

Manny thanks Erik

Erik hoeven
  • 1,442
  • 6
  • 26
  • 41
  • Pyodbc is notoriously annoying to deal with. Can you install other packages on Linux by chance? The problem will be solved by sudo apt installs, not via pip. – John Stud Oct 31 '21 at 20:28
  • How do i do apt-install with azure function? – Erik hoeven Oct 31 '21 at 22:04
  • Before running the command `func start` or `func host start`, did you run these both commands `pip freeze > requirements.txt` and then installing the libraries inside the virtual environment after activating it `pip install -r requirements.txt` and run the main command `func host start` and check it. –  Nov 02 '21 at 03:26

1 Answers1

1

How do i do apt-install with azure function?

You can do this using a custom container and execute any commands like sudo apt-get install python3-venv using bash, PowerShell and CMD.

Before running the command func start or func host start, run these both commands pip freeze > requirements.txt and then installing the libraries inside the virtual environment after activating it pip install -r requirements.txt and run the main command func host start.