Open JackH11 opened 1 year ago
For me this was caused by two things, relative imports being funky and initializing classes outside of Azure functions. Code base was Python.
The lack of error logs was frustrating. 😭😭
For me fix was to set Node version to 20 (was 18). Error message are really useless.
I was struggling with this for a few hours. Turns out that I needed to configure the Azure Function to be 64-bit instead of the default 32-bit.
I had to revert to NodeJs V3, which gave me the exception that I needed.
Keeping this issue open to help others landing here. Even though we're covering a wide array of related issues in one.
After trying all above recommondations I still did not succeded to get de Functions visible. The deployment went well, only no function triggers could be found. Running V4, Python 3.10, deploying with ZIP deployment from Azure DevOps
But I got it working again! I did 2 things, but not sure which one did the trick...
I added a Try Except statements around my import packages. Like so:
When importing packages the function won't crash on error and will show the function triggers. But when running the Azure Function it will show a runtime error, hopefully with a message thats meaningfull.
Secondly I added fixed versions to my requirements.txt. Like so:
I noted that package azure-storage-file-datalake was just updated to a new version. (the next day there was already a .1 version which suggest there was a issue within the package) Locally everything workt. Even after removing all installations with PIP and reinstall the latest version. But I am developing on Windows and the Functions online runs with Linux.. so maybee that may have an influence.
Sadly I couldn't reproduce the issue so I am not 100% sure what got the function working again.
This solved it. But I believed the solution is because of the pkg version. I updated the requirement.txt file of mine to the same version of my running on my local machine. I didn't put the try and except and it magically working. So it looks like some of the updated pkg is preventing the importing process.
After trying all above recommondations I still did not succeded to get de Functions visible. The deployment went well, only no function triggers could be found. Running V4, Python 3.10, deploying with ZIP deployment from Azure DevOps But I got it working again! I did 2 things, but not sure which one did the trick... I added a Try Except statements around my import packages. Like so: When importing packages the function won't crash on error and will show the function triggers. But when running the Azure Function it will show a runtime error, hopefully with a message thats meaningfull. Secondly I added fixed versions to my requirements.txt. Like so: I noted that package azure-storage-file-datalake was just updated to a new version. (the next day there was already a .1 version which suggest there was a issue within the package) Locally everything workt. Even after removing all installations with PIP and reinstall the latest version. But I am developing on Windows and the Functions online runs with Linux.. so maybee that may have an influence. Sadly I couldn't reproduce the issue so I am not 100% sure what got the function working again.
This solved it. But I believed the solution is because of the pkg version. I updated the requirement.txt file of mine to the same version of my running on my local machine. I didn't put the try and except and it magically working. So it looks like some of the updated pkg is preventing the importing process.
Thank you so much! I also encountered the same problem because I didn't include a package in requirements.txt.
Solved my issue. psycopg2 does not work. Use psycopg2-binary instead. After uninstalling psycopg2, installing psycopg2-binary, and updating requirements.txt, the app was able to publish. Had to roll back to the Azure Functions Python V1, publish, and then review error messages to sort this out.
Would be good if psycopg2 could work since "the binary package is a practical choice for development and testing but in production it is advised to use the package built from sources" according to https://pypi.org/project/psycopg2-binary/.
From the V1 error message:
Exception while executing function: Functions.HttpExample Result: Failure Exception: ImportError: libpq.so.5: cannot open shared object file: No such file or directory. Please check the requirements.txt file for the missing module. For more info, please refer the troubleshooting guide: https://aka.ms/functions-modulenotfound Stack: File "/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/dispatcher.py", line 380, in _handle__function_load_request func = loader.load_function( File "/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 48, in call raise extend_exception_message(e, message) File "/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 44, in call return func(*args, **kwargs) File "/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/loader.py", line 132, in load_function mod = importlib.import_module(fullmodname) File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1050, in _gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/home/site/wwwroot/HttpExample/__init__.py", line 5, in <module> import psycopg2 File "/home/site/wwwroot/.python_packages/lib/site-packages/psycopg2/__init__.py", line 51, in <module> from psycopg2._psycopg import ( # noqa
Thanks a lot. You are a life saver. Its unfortunate that psycopg2 still doesn't work.
Same issue here. For me the solution was to add to azure function all the app settings and then deploy. I thought I could deploy and then add the settings but it didn't workout this way. It should be somewhere in the documentation
Referenc
THIS IS SUPER SMART
WIth this trick the functions were loaded, then I was able to see them, but I wasnt able to execute them because the api key page was not loading (internal server error).
So I changed my functions to ANONYMOUS and tried again, and indeed I was missing a setting in key vault which is loaded in the imports!
Microsoft! please fix t his with logging at least! this is very difficult to debug.
I've tried switching to Pyton 3.10, using try/except on imports, checked app settings, changed to ANONYMOUS and it still locally it works perfect, but cant deploy. Very frustrating
Dropping down to Python 3.10 (from 3.11) fixed the "No HTTP triggers found" for me VS Code 1.83.0
I confirm, downgrading python version from 3.11 worked for me as well.
PS: Downgraded to py3.9
This was working fine until today, now deployments that worked before magically don't work. Not sure what changed since most package versions are pinned. Py311, maybe downgrading could help, but that would be a lame workaround.
After hours of changing settings, restarting, checking logs, still can't get it to work. Not a missing package issue, seems to start up just fine. Initialized the warmup function and loaded sklearn, no missing package errors. Still no HTTP triggers found. Can't figure it out.
Bug Report
At what date and time did you most recently experience the problem? Experiencing this problem on 1/2/2023
Where did you experience the problem? E.g. Azure Web Apps, Azure Functions, Azure Container Registry, or offline use. Experienced the problem while trying to deploy an HTTP request-triggered function to azure.
If your repo is publicly available please share its URL: I used VSCode Azure Functions extension to create a quick-start http request. I also created a python virtual environment to run locally.
What happened? I followed this walkthrough: https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-python?pivots=python-mode-decorators#publish-the-project-to-azure, with the only change I made found here: https://github.com/MicrosoftDocs/azure-docs/issues/103178.
The function and trigger work when testing locally through azurite. Once I got to deploying the function from vscode, I received the output: "No HTTP triggers found". The function and trigger work when testing locally through azurite.
After the upload has been attempted, I can however see the project files that I uploaded under the "files" dropdown when viewing azure subscription through vscode.
What did you expect or want to happen? I expected the function to deploy
How can we reproduce it? Follow the walkthrough and make the replacement.
Do you have log output? Please include between the backticks: