azure-functions-python-worker: Azure function python v2 with external packages HTTP Trigger not visible in Azure Portal after deployment
Refer this SO Thread and my answer - https://stackoverflow.com/questions/76458717/why-is-the-functions-runtime-not-finding-my-functions-when-i-import-certain-pack/76463210?noredirect=1#> The Azure python Function with V2 programming model including external packages and imports in function_app.py works locally, But when I deploy it in Azure the Function Trigger is not visible. If I deploy default HTTP Trigger with python v2 programming model, The trigger is visible after deployment. But not when i add custom imports in the function_app.py and requirements.txt. Refer this image - https://i.imgur.com/CjCnsY8.png but the function files are visible in app files like here- https://i.imgur.com/R3SZWcW.png . I tried the deployment with App service plan and consumption plan both, Still no luck. I also added AzureWebJobsFeatureFlags:EnableWorkerIndexing settings, I also tried to deploy this function as zip using azure cli zip command with required settings to deploy function as zip, I also tried to deploy it with function core tools func azure functionapp publish <function-app> command and also via VS code still no luck.
Investigative information
Please provide the following:
- Timestamp:
- Function App name: siliconfunc311
- Function name(s) (as appropriate): Http trigger pythonv2
- Core Tools version:4.0.5148
Repro steps
Provide the steps required to reproduce the problem:
Refer this SO thread and my answer- https://stackoverflow.com/questions/76458717/why-is-the-functions-runtime-not-finding-my-functions-when-i-import-certain-pack/76463210?noredirect=1#comment134830419_76463210
Expected behavior
Provide a description of the expected behavior.
after deployment HTTP trigger should be visible in Azure portal
Actual behavior
Provide a description of the actual behavior observed.
Function trigger is not visible in Functions section of Function tab but files are visible in app files
Known workarounds
Provide a description of any known workarounds.
Contents of the requirements.txt file:
Provide the requirements.txt file to help us find out module related issues.
numpy
pandas
opencv-python-headless
librosa
torch
torchaudio
torch-audiomentations
torchvision
azure-functions
Related information
Provide any related information
- Links to source
# function_app.py
import logging
import azure.functions as func
import numpy as np
import pandas as pd
import cv2
import librosa
import torch
import torchaudio
import torch_audiomentations
import torchvision
from azure.functions import HttpRequest
app = func.FunctionApp(http_auth_level=func.AuthLevel.FUNCTION)
@app.route(route="HttpTrigger")
def HttpTrigger(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
#code block with imported packages
arr = np.array([1, 2, 3])
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
image = cv2.imread('Screenshot (1).png')
audio_data, sample_rate = librosa.load('sample.wav.mp3')
tensor = torch.tensor([1, 2, 3])
transformed_tensor = torch_audiomentations.PitchShift(sample_rate=sample_rate, p=1.0)
torchvision.transforms.ToTensor()(image)
name = req.params.get('name')
if not name:
try:
req_body = req.get_json()
except ValueError:
pass
else:
name = req_body.get('name')
if name:
return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
else:
return func.HttpResponse(
"This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
status_code=200
)
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 21
- Comments: 111 (2 by maintainers)
FWIW, I did find a way to find the error message. It’s tough to get to, so I’m making a note of the steps.
This is a suitable place to find your error message ONLY if the following:
open()command that reference a file)Go to “Diagnose and solve problems” and then go to “Diagnostic Tools”.

Go to the search and search for “Functions that are not triggering”
Find “Functions that are not triggering” (there is no way to ‘pin’ this report, so you just have to hunt around for it)
You’ll find the exception in the text.
If you scroll down, you can see the error trace, in one long string. Copy and paste that into VSC, format it, and you can read the error message as it would normally appear.
This is a tedious process, but you will be able to see your error without building any special tools.
Some limitations:
For whomever comes here in utter despair like I did; I’ve created a demo on when this issue occurs. With ‘issue’ I am pointing at the situation where a FunctionApp is successfully deployed but the Functions themselves don’t show up.
In essence, the problem lies in the code base (duh). If there is any error while loading your project, then Azure Functions will silence that and instead just won’t show any of the Functions in your Function app. It’s extremely hard to debug, as you have absolutely no idea what is going wrong. You can even get into the situation where it works locally, but not on Azure Functions. A possible cause for that is that you are testing it locally on a different OS (Windows for example) than where it will be deployed (Linux), and you are doing a *zip-deployment where the packages you zipped, contain Windows-specific binaries.
I am not saying this is specifically the case if you run in this issue. I am saying this is an example of an issue that is kept silence by Azure Functions so you can go down a completely unrelated rabbit hole.
The reproduction is here (https://github.com/JarroVGIT/azure-functions-python-v2-load-issue), with examples when it will and will not work. Hope it helps somebody save a day or two 😉
I was able to solve this by including all dependencies my app used in my
requirements.txtfile. I was able to solve it with the help of @saari-oj 's comment where they only had theimport azure.functions as funcas the only import.I then saw that my
requirements.txtfile only had that dependency listed. When I added my other project dependencies to the requirements file, it worked! My guess is, when deploying from VS code, the tool creates a .zip dir of the project, uploads it to Azure and Azure does a pip install from the requirements.txt.To update your project dependencies, make sure to update your requirements.txt file by running:
pip freeze > ./requirements.txtI’m using the v2 model, Python (v3.10) func app.
Why is this issue closed? Can it please be re-opened, this is still a pending issue which apparently lot of people are facing.
I wanted to share my experience with this issue. I encountered the same error: “No job functions found. Try making your classes and methods public.” Despite trying various solutions, nothing seemed to work. Here are the steps I took to resolve this issue:
Access the SSH Web Interface:
Navigate to the Project Directory:
Install Azure Functions Package:
Start the Project Using the Local Environment Command:
After doing all that, I got the following error:
Offending Line of Code:
The issue arises because Azure function app servers use Python 3.11, where f-strings with double quotes inside double quotes are not allowed. This kind of syntax is fixed in Python 3.13.
I hope this helps others facing the same problem. Why was this error not logged in the application’s logs? It would have saved me countless hours of debugging.
This is high priority for us in the Functions team and we will have more information and a troubleshooting guide in the coming days - thank you all for your patience and feedback!
Thanks for looking into this.
Do we know if this problem is one multiple people are facing, and there is nothing we can do to deploy with Python v2 programming model?
All these issues… Just adding to this thread to keep it visible. Seems like the lack of any telemetry from functions that fail to deploy is the main problem here. It also does not help that there is a delay between the time the azure portal tells you your function has been deployed to when its actually available for calling. We literally have to deploy our stuff line for line to figure out what is erroring and add comments to the code so we can see what we are actually running. Is there anyone from MS looking into this?
Adding my experience and solution FWIW.
Similar to many people I was having issues once I added external packages. But the errors are lost due to the above mentioned azure functions poor design, and the function still deploys correctly. The only logs I could see would say:
My solution - put the imports in a try/catch, do not raise the error so the function deploys correctly, but set it to a global variable (
initialization_error).Add a
/healthendpoint, and return the error that happens during initialization, as well as other debug info (used pandas as the test import here.In my personal case, the actual error that was getting swallowed by azure functions became clear from this health_check response. It was a mismatch in compatible versions between numpy and pandas.
So while ultimately my fault, azure functions made it a PITA to debug. Hope this helps someone else!
It’s impossible to fix the issue without proper log. The Azure support states that such logs are “internal”. So, it’s easier to debug a microcontroller than a Azure Functions. The support gives the log, but it’s a hit or miss, in my case the issue is related to “requests” dependency, but I can’t fix that nor I know if that is the only issue.
Well, the Microsoft quality standard: poor documentation, poor software design and terrible service.
Luckily, I need to use it for just couple of months: then I’ll move everything to a bare-metal (cheaper, faster and easier).
Also ran into the issue, would be great to have logging for function compilation, it’s not workable without it, makes troubleshooting ultra hard… already lost hours
Hi all,
I was running into the same issues mentioned above. I was using the Deployment Center in the Azure Function App to connect it to my GitHub, and no matter which packages I installed inside my requirements.txt file—even something as common as requests—the function trigger would not show up in the portal when deployed because it couldn’t find the packages.
The solution I found was to zip up the library packages during the GitHub build instead of letting Oryx do the remote build. Here are the changes I made to the GitHub workflow file to achieve this:
pip install --target=".python_packages/lib/site-packages" -r requirements.txtzip release.zip .python_packages ./* -rscm-do-build-during-deployment: falseenable-oryx-build: falseThis way you can still use the V2 programming model and can use Github Actions instead of VSCode to deploy to the Azure Function.
Perhaps this only applies when you run locally, but I got this error after running
func start:I simply followed the steps as learn.microsoft.com and did some minor edits to the function (and added some packages) before attempting to run.
The fix for me was to change the auth_level enum from
func.AuthLevel.Anonymoustofunc.AuthLevel.ANONYMOUS, i.e.:I’m rather new to Python, so this may or may not be related to this issue, but I thought I’d post it in case it would help someone.
This is my last message in this thread and then I am going to unsubscribe. A ton of people just post ‘me too’ or seem to not have read anything in this long thread, especially where I think I have done a pretty decent job in describing why you see this behavior here https://github.com/Azure/azure-functions-python-worker/issues/1262#issuecomment-1771988661 .
In your case, you take a extremely non-straightforward python dependency (
sanic), don’t mention any details about how you deploy, on what OS you work, on what OS you deploy from, what OS you deploy to, what kind of plan you use or with which dependency you deploy (are you usinguvloop? orujsonwith sanic?). All of which are crucial in solving your issue. It is clear that Azure Functions in this respect does not provide the user experience that we all would have liked to have, but just complaining that it is “catastrophic” doesn’t help you much either and frankly might only be counterproductive for the rest of us.I wish you the best of luck, I just don’t want these kinds of posts in my inbox anymore.
Hi All - I had exactly the same issue. Locally everything runs fine but when deploying to ASP I cannot see the functions.
After I removed ALL the imports (expect for azure.functions) from beginning of the file and added the imports under the method(s) that used them, then it started to work.
So DONT do it like this:
Did this problem start recently?
I had a v2 programming function app deployed that was working fine, however last night i made some changes and I can no longer see the functions. I’ve tried everything and attempting to revert to the old code but I can’t seem to see what is different.
Maybe Azure have made some changes that have impacted us?
Plus one.
It is very frustrating to debug issues that occur outside of the function definition.
For example, import errors, missing dependencies, or issues with the binding and trigger definitions.
We are essentially flying blind when trying to debug these problems.
Azure Functions should provide more access to logging that can lend a light to these issues.
Just another kudos to @BillmanH for redirecting a lost brother back to the light.
If you are a newbie that created a toy app with “func init”, it is essential to update the requirements.txt file before deploying with:
pip freeze > requirements.txtif you just add the names of the packages without the version numbers (as a newbie could think is the right way after inspecting the auto-generated requirements.txt, that only has “azure-functions” listed), you are in for trouble.
I am also facing the issue and just tried the method proposed by @robmitchellzone.
Code then looks something like that
Still, host log says: 2023-09-19T08:24:23.828 [Information] 1 functions found (Custom) 2023-09-19T08:24:23.828 [Information] 0 functions loaded
Code works fine when deploying from local.
What I am seeing is this log:
And the app function doesn’t appear in the functions tab, but the file do appear under app files. The exact same python code deployed to a different environment is working fine.
I’m experiencing a similar issue but with two differences:
One additional thing I’ve noticed when I’ve probed around in my portal is that Genie is reporting the following error:
That is followed by this error:
The key thing that strikes me as odd here is that it’s failing to import the package from /home/site/wwwroot/.python_pacakages/…
Looking in my storage account, the reason it’s failing is obvious - there’s no .python_packages file in wwwroot.
After liaising with the OP of this github issue on my own SO post, we’re using identical Azure Pipeline YAML definitions. The key thing is we’re both running from zip packages, rather than deploying the code directly so I wouldn’t expect there to be anything in wwwroot.
Since my function_app.py file imports a load of custom packages (which in turn import PIL), and does so before declaring the function, my thinking is that the imports are erroring about because Python should be looking for them in the package but is actually looking for them in the site root (working directory). Since they aren’t there, it errors out so never makes it as far as far as the function app declaration.
Just a guess but given the errors it would make sense.
What to do about that, however, I don’t know!
For now it looks like the two workarounds are:
I followed the first of these options and this resolved my issue.
Thanks for opening this issue. We are working on providing visibility into errors that happen when function host starts in AppInsights soon so you will be able to find out what failed and fix the app. We are also working on shifting these errors to deployment time.
This was absolutely the solution that worked for me! Thank you so much!
My problem was with FastAPI + Function Apps. Everything worked fine locally, but when I deployed, it all looked fine (no error logs I could find) but there would be no actual functions/my API would return 404s. It’s probably due to uncaught, top-level errors (i.e. at module load time).
If you can’t use a different service, I recommend starting with this: https://github.com/Azure-Samples/fastapi-on-azure-functions, and very slowly moving your code over into that repo, committing each time you get it working. You’ll be able to find what bit of code is problematic that way.
I also came across this general issue of functions not loading; I can’t believe this is still an issue. Seems to me, the main issue is that errors are being (effectively, at least) lost/not accessible; specifically startup errors. In turn, function not loading problems like these are almost always startup issues, but you cannot fix them (at least not in any good way) since the errors don’t come through anywhere. Here’s my observation/breakdown:
Startup logging issue
When loading functions (doing indexing at startup) at some point a
importlib.import_modulecall is made, which throws (from the code in the module that is being imported.) - This exception is “lost”; that’s the problem. I.e. If anything is catching it, it doesn’t end up showing anywhere that a user can access/find (e.g. via azure portal.) Anything crashing startup would give failed to load functions issue, it seems. Common reasons mentioned:All such startup issues aren’t logged at all, or not exposed to the user. User can’t do much about this, there’s no workaround fix the user can do. The only real way is a very tedious process of elimination to find what triggers the crash and fix it, but if we had the error info it wouldn’t be a problem.
User logging issue (once you get past the startup issue)
Initial setup of the root logger is not working. It seems that, at start of user code running, the root logger has one handler attatched (AsyncLoggingHandler).
However, the existing handler doesn’t seem to be doing anything useful. As in, I don’t know where it’s emiting logs to/what it’s doing with them, but it’s nowhere to be found. This is the other issue. Same lost errors problem, but for different reason. And so logging at module-level doesn’t work. E.g. you could wrap module-level code in a try catch swallowing the error (so no immediate crash, allowing functions to load) but logging the event, the log wouldn’t come through anywhere. There is a workaround for this; add a working handler to the root logger: I put this as first thing in my main/root app module (
function_app.py):Now doing something like
logging.info("t")comes through in app insights trace logs, and everywhere else. This is basically all one big logging problem.AZ Functions will not show the HTTP triggers if something goes wrong.
For this specific issue of not being able to use an external package, I had the following workaround:
A simple and dirty fix is copying all installed packages to the root dir of your application, in other words, in your
.github/workflows/<YOUR_WORKFLOW>.ymlyou can add after you install your packages and before zipping the release:The command
cp -r $(python -c 'import site; print(site.getsitepackages()[0])')/* .will copy all packages you installed and add them in your app root dir.Just, please, bear in mind this is not optimal (neither pretty) and if you can have issues if one of the files in your pip env has the same name as one (or more) files in your root.
Good luck! 😃
Sadly, no ssh in free consumption plan (Y1)… But the solution seems great For those with consumption plan, you may try klettg message (https://github.com/Azure/azure-functions-python-worker/issues/1262#issuecomment-2468971382), putting import in a try/except + add an anon endpoint to return the error (a real waste of time, but it works 🥇 )
@AhHanie this comment is a blessing! Running locally was working for me but deploying to the cloud was not, then I tried running locally in a different machine and it failed with the f-string error, but I didn’t know double quotes were not allowed. Thank you! Also thanks @BillmanH, adding the functions to host.json was the secret for me. Now I’m just struggling to deploy using Azure Pipelines.
kudos to @BillmanH
pip freeze > ./requirements.txt Worked for me like a hero.
I just want to specifically thank @BillmanH , this has been a plague on my existence the last few days until I finally saw your comment.
Can you try adding a list of functions in that script that you want to load?
@BillmanH I am able to run the function locally. I believe that my host.json is alright:
I am starting to worry it may just be an issue with the flex consumption plan. The odd things is what by deploying through the Azure VSCode extension, I can see all the triggers fine, and then as soon as I redeploy the resources via Bicep, they disappear.
1 functions found. 0 function loaded. No job functions found., is most likely an issue with your code, and most likely either A) a module that is not in your requirements, or B) a variable declared outside of the function scope.I wrote a more comprehensive troubleshooting guide. But, there isn’t much else I can do without seeing your code. https://github.com/BillmanH/exoplanets/blob/main/docs/Troubleshooting_azure_functions.md#how-to-see-the-specific-error
even with the Flex plan, you should still be able to access the diagnostic tools.
I am trying to deploy a function app using the Flex Consumption plan. I have tried using the v1 model, v2 model, and reverted back to the simple HttpExample with no external python modules, yet I still do not see any of my http triggers. I am correctly using the WEBSITE_RUN_FROM_PACKAGE environment variable and have it linked to the blob of the zip containing the function app code. I manually sync the triggers as part of my deployment pipeline as well. I have tried everything that @JackDDavis tried + more, and currently have no external modules, yet I still see nothing. In the trace logs I get
1 functions found. 0 function loaded. No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).Because this is a Flex Consumption plan, I am unable to see more detailed logs as @BillmanH suggests. Any insights would be much appreciated.Anyone got it working?
@BillmanH, thanks for sharing your discovery of diagnostics. This helped me identify that the function app did not load a critical library for the ‘psycopg’ module which caused it to fail. Details in diag pointed me to https://aka.ms/functions-modulenotfound and ultimately nested guidance to Update your package to the latest version. Following others, I previously tried:
Ultimately, changing my requirements file to using the binary version again (which I had done before) but this time WITH the current version appended (psycopg[binary]==3.1.19) seemed to force it to load the dependencies that kept failing. Finally got it back working. Hopefully in the future this is handled appropriately by the function and all dependencies are in fact loaded. But until then, I hope this helps others
EDIT: psycopg[binary]
@BillmanH you’re my hero! Was banging my head against the wall until I found your tip. In my case I had a variable declared outside a function. Once I moved it and redeployed the app, the functions load. Thank you!!
I can confirm people’s observations that this is a dependency issue. My code has a dependency on another package I published privately where I forgot to list
jsonschemaas a requirement, as insetup(install_requires=[<jsonschema goes here>])insetup.py. Before fixing that issue I commented out parts of my project and reproduced the situations of finding / not finding the azure functions when publishing by importing / not importing the missing dependency to my code (I commented out the private dependency import to get rid of the transitive import).I also verified that jsonschema was not being built on the remote build.
After adding jsonschema to my current project’s requirements.txt file it worked, and of course, I also expect it to work when I fix the
install_requireson my privately published dependency.This explains why
pip freeze > ./requirements.txtsolves the symptom, but obviously the real issues are that:Thanks, @Soggywaters, this is what worked for me. Since that’s two people in this thread where this worked as a solution, I’m guessing this is a more common reason people are unable to deploy their functions.
Same problem here. Linux, python, consumption plan using the v2 function model, zip deployment. I cannot find any code errors. Functions found 1, loaded: 0. It started happening out of nowhere after a small code change, but a quick reversion and re-deploy did not fix this. Based on a couple days of investigation it appears that the dependencies are failing to build silently during the deployment process. I haven’t caught this because I’m on the Linux consumption plan and I don’t have much of a window into what goes on during zip deployment.
I’ve found that building the dependencies locally in a Docker container during pre-deployment will circumvent the issue.
func azure functionapp publish <app_name> --build-native-depsI’ve tested this by confirming that the functions do not trigger when running the same command with
--build remoteinstead of--build-native-deps. Strangely enough, sometimes deploying regularly (via VSCode Azure extension) will work again after doing it this way, but adding the--build-native-depsflag to the.vscode/settings.jsonfile as a PreDeployTask doesn’t seem to do anything.Due to the fact that this is only one of several errors that could cause Azure Functions to not register upon a successful deployment (see @JarroVGIT’s demonstration above), this is a failure of the Linux webapp consumption plan by not giving us much of a window into the zip deployment process for the purpose of debugging. The SCM site is nearly useless.
EDIT: In my specific case, updating
requirements.txtwith the output of$ pip freezesolved all my problems.All I have in my requirements.txt is azure-functions, and still getting it.
Very much useful, thank you for the insight @JarroVGIT. My python code would execute on the local host, but the function would never pop up in Azure, in spite of a successful deployment. Logs were basically limited to “Function Found: 1, Function Loaded: 0”. After hours of troubleshooting, I simply realized that I’d set psycopg2 as a requirement instead of psycopg2-binary (pg engine driver, and of course postgres was not readily available as a binary on the Service Plan). It is highly confusing for a dev as Azure reported the Function deployment as successful, and not a single error or warning was logged.
Correct. I ran I to a smililar issue in a python v1 app last year. I forgot that I had to add that dependency again. Apparently v4 of the protobuf package had breaking changes.
Still having this issue. Also I’m trying to implement Azure Durable functions as well. I connect with FTP and confirm that the /home/data/SitePackages has been updated after deploying from Github actions. The logs claim a succesfull deployment but no files/functions are detected by Azure. (Python v2)
I’m on EP1:3 service plan. This really is a critical issue to solve.
@shahztechfarm, I had variables declared above my function definition in my
blueprint.pyfile. Moving those statements to within the function allowed Azure to detect the function when deployed to the cloud.I am also experiencing the issue. Local running works fine but deployment using VSCode and the CLI result in no functions being shown in the Azure Portal with no error messages being thrown.
I am having the same issue with my functions no showing/loading. Everything works locally & debugging but when pipelines or vscode deploys to the function it succeeds but never shows any functions.
I had a similar issue, my Azure Function worked perfectly in local testing. Deployment was succesful, but no triggers were shown. I could not find any logs showing any errors at all.
I downgraded to the v1 python worker based on the discussion in this thread. Using the v1 worker, the trigger was created, but I could see it generated an error when trying to import the
psycopg2package, changing the requirements.txt to usepsycopg2-binaryfixed this issue. Retrying the v2 python worker using thepsycopg2-binarypackage worked and the trigger showed up succesfully. I think this is similar to the issue @VirajVaitha123 was experiencing.It appears the v2 worker doesn’t show an error message and doesn’t create the trigger where the v1 worker does.
Can you reproduce it on your end with the code in the question? with python function v2? The trigger won’t be visible in the portal despite all the solutions in v2. It works in v1