Azure-Samples/fastapi-on-azure-functions

Customer packages not in sys path.

Opened this issue · 2 comments

Please provide us with the following information:

This issue is for a: (mark with an x)

- [X] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Clone repo. Then run:

python -m venv . venv
pip install -r requirements.txt
func start

Any log messages given by the failure

[2024-02-10T16:12:42.877Z] Customer packages not in sys path. This should never happen!

[...]

Worker failed to index functions
[2024-02-10T16:12:43.200Z] Result: Failure
Exception: ModuleNotFoundError: No module named 'fastapi'. Troubleshooting Guide: https://aka.ms/functions-modulenotfound
Stack: File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.11\WINDOWS\X64\azure_functions_worker\dispatcher.py", line 345, in handle__functions_metadata_request
fx_metadata_results = self.index_functions(function_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.11\WINDOWS\X64\azure_functions_worker\dispatcher.py", line 617, in index_functions
indexed_functions = loader.index_function_app(function_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.11\WINDOWS\X64\azure_functions_worker\utils\wrappers.py", line 48, in call
raise extend_exception_message(e, message)
File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.11\WINDOWS\X64\azure_functions_worker\utils\wrappers.py", line 44, in call
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.11\WINDOWS\X64\azure_functions_worker\loader.py", line 214, in index_function_app
imported_module = importlib.import_module(module_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\importlib_init
.py", line 126, in import_module
return _bootstrap.gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jonny\dev\magpi\fastapi-on-azure-functions\function_app.py", line 3, in
from WrapperFunction import app as fastapi_app
File "C:\Users\jonny\dev\magpi\fastapi-on-azure-functions\WrapperFunction_init
.py", line 3, in
import fastapi

Expected/desired behavior

Function should start

OS and Version?

Windows 11.

Versions

Azure Functions Core Tools
Core Tools Version: 4.0.5455 Commit hash: N/A (64-bit)
Function Runtime Version: 4.27.5.21554

Mention any other details that might be useful

Same issue when I try on my own repo (with similar architecture).


Thanks! We'll be in touch soon.

I had the same issue. Upgraded Azure Function Core Tools to version 4.0.5530 (having Function Runtime Version 4.28.5.21962); and removed the Windows Store version of Python I had installed to one managed by pyenv (3.10). Now I no longer get a failure when starting the app locally with func host start.

I am using windows 11 and I have same issue!

Versions:

Found Python version 3.11.9 (python3).
 
Azure Functions Core Tools
Core Tools Version:       4.0.5700 Commit hash: N/A +71cc84964a60bfb07d95839b7c666bd239507bdd (64-bit)
Function Runtime Version: 4.33.2.22572