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

https://stackoverflow.com/questions/76458717/why-is-the-functions-runtime-not-finding-my-functions-when-i-import-certain-pack/76463210?noredirect=1#comment134830419_76463210

# 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)

Most upvoted comments

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:

  • your app deployed successfully, but isn’t showing in the functions list.
  • The app is crashing because of an issue with your code e.g.:
    • Module not loading
    • File path issues (mine was in open() command that reference a file)
    • Syntax that crashes on load rather than when the function is called. For example an issue that crashes when defining a function, before the function has been run. Like a missing library, bad requirements.txt files, etc.
  1. Go to “Diagnose and solve problems” and then go to “Diagnostic Tools”. image image

  2. Go to the search and search for “Functions that are not triggering” image

  3. Find “Functions that are not triggering” (there is no way to ‘pin’ this report, so you just have to hunt around for it) image

  4. You’ll find the exception in the text. image

  5. 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. image

This is a tedious process, but you will be able to see your error without building any special tools.

Some limitations:

  • Finding that report is a pain.
  • You have to wait a while for your error to show up here. So you end up waiting.

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.txt file. I was able to solve it with the help of @saari-oj 's comment where they only had the import azure.functions as func as the only import.

I then saw that my requirements.txt file 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.txt

I’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:

  1. Access the SSH Web Interface:

    • In the Azure Portal, navigate to your function app page.
    • Go to Development Tools -> SSH on the side menu.
  2. Navigate to the Project Directory:

    cd ~/site/wwwroot
    
  3. Install Azure Functions Package:

    apt-get install azure-functions-core-tools-4
    
  4. Start the Project Using the Local Environment Command:

    func host start
    

After doing all that, I got the following error:

Exception: SyntaxError: f-string: unmatched '[' (file.py, line 83)

Offending Line of Code:

text += f"{node["value"]}"

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:

info: Host.Startup[315]
      0 functions loaded
info: Host.Startup[0]
      Generating 0 job function(s)
warn: Host.Startup[0]
      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.).
info: Microsoft.Azure.WebJobs.Script.WebHost.WebScriptHostHttpRoutesManager[0]
      Initializing function HTTP routes
      No HTTP routes mapped

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 /health endpoint, and return the error that happens during initialization, as well as other debug info (used pandas as the test import here.

import logging
import azure.functions as func
import sys
import os
from importlib.metadata import distributions
import json
import traceback

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

# Initialize the FunctionApp before any other initialization
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)

# Global variables to track initialization status
services_initialized = False
initialization_error = None

try:
    import pandas as pd
    logger.info("All services initialized successfully")
except Exception as e:
    initialization_error = str(e)
    logger.error(f"Initialization error: {str(e)}")
    # Don't raise - let the functions register

@app.function_name("health")
@app.route(route="health", methods=["GET"])
def health_check(req: func.HttpRequest) -> func.HttpResponse:
    try:
        health_info = {
            "status": "available",
            "initialization": {
                "services_initialized": services_initialized,
                "initialization_error": initialization_error,
            },
            "environment": {
                "python_version": sys.version,
                "current_directory": os.getcwd(),
                "python_path": sys.path,
                "environment_variables": {
                    "PYTHONPATH": os.getenv("PYTHONPATH", "not set"),
                    "AzureWebJobsScriptRoot": os.getenv("AzureWebJobsScriptRoot", "not set"),
                    "WEBSITE_SITE_NAME": os.getenv("WEBSITE_SITE_NAME", "not set"),
                },
            },
            "filesystem": {
                "directory_contents": os.listdir(),
                "wwwroot_contents": (
                    os.listdir("/home/site/wwwroot") if os.path.exists("/home/site/wwwroot") else "not found"
                ),
            },
            "dependencies": {
                "installed_packages": [f"{dist.metadata['Name']}=={dist.version}" for dist in distributions()],
                "pandas_version": pd.__version__ if "pd" in globals() else "not imported",
            },
        }

        return func.HttpResponse(json.dumps(health_info, indent=2), mimetype="application/json")
    except Exception as e:
        error_info = {
            "status": "error",
            "error_type": type(e).__name__,
            "error_message": str(e),
            "error_traceback": traceback.format_exc(),
        }
        logger.error(f"Health check failed: {str(e)}")
        return func.HttpResponse(json.dumps(error_info, indent=2), status_code=500, mimetype="application/json")

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.

{
    "status": "available",
    "initialization": {
        "services_initialized": false,
        "initialization_error": "numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject"
    },

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:

  1. Inside the “Install dependencies” step of the build job, change the pip install command pip install --target=".python_packages/lib/site-packages" -r requirements.txt
  2. Inside the “Zip artifact for deployment” step of the build job, change the zip command so it includes the python_packages zip release.zip .python_packages ./* -r
  3. Inside the “Deploy to Azure Functions” step of the deploy job, change these values so it doesn’t do a remote build scm-do-build-during-deployment: false enable-oryx-build: false

This 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:

[2024-04-17T17:32:04.277Z] Worker failed to index functions
[2024-04-17T17:32:04.277Z] Result: Failure
[2024-04-17T17:32:04.277Z] Exception: AttributeError: Anonymous

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.Anonymous to func.AuthLevel.ANONYMOUS, i.e.:

@app.route(route="xxxx", auth_level=func.AuthLevel.ANONYMOUS)

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.

Same issue. I have been going mad trying to figure this out.

I tested this as follows:

  • barebones function app with no imports other than std lib and local modules = works locally, http triggers are found when deployed
  • exact same function, only add one third-party library (sanic, picked at random). The virtual environment has sanic installed. The app works fine locally, but when you deploy to Azure using the VSCode extension, no http triggers are found

@shreyabatra4 I understand your team is working on this, but this is catastrophic because it means functions that depend on third-party packages cannot be deployed or updated, at all.

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 using uvloop? or ujson with 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:

image

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.txt

if 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

... Imports ...

app = func.FunctionApp()

@app.function_name(name="mytimer")
@app.schedule(schedule="0 0 */6 * * *", arg_name="mytimer", run_on_startup=True)
def main(mytimer: func.TimerRequest) -> None:
    # Non-main functions were moved to inner functions
    def get_project_json():
        devops_access_token = os.environ['DEVOPS_READ_TOKEN']

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:

[Information]   1 functions found
[Information]   0 functions loaded

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:

  1. I’m using a timer trigger rather than an HTTP trigger
  2. I’m getting the error '1 found, 0 loaded" in my logging as opposed to the error displayed in the SO post.

One additional thing I’ve noticed when I’ve probed around in my portal is that Genie is reporting the following error:

Worker failed to index functions
Result: Failure Exception: ImportError: cannot import name '_imaging' from 'PIL' (/home/site/wwwroot/.python_packages/lib/site-packages/PIL/init.py). Troubleshooting Guide: https://aka.ms/functions-modulenotfound Stack: File '/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/dispatcher.py', line 338, in _handle__functions_metadata_request fx_metadata_results = self.index_functions(function_path) File '/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/dispatcher.py', line 607, in index_functions indexed_functions = loader.index_function_app(function_path) 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 151, in index_function_app imported_module = importlib.import_module(module_name) File '/usr/local/lib/python3.10/importlib/init.py', line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File '', line 1050, in _gcd_import File '', line 1027, in _find_and_load File '', line 1006, in _find_and_load_unlocked File '', line 688, in _load_unlocked File '', line 883, in exec_module File '', line 241, in _call_with_frames_removed File '/home/site/wwwroot/function_app.py', line 2, in from core.data.training_image_filestore import TrainingImageFilestore File '/home/site/wwwroot/core/data/training_image_filestore.py', line 1, in from PIL import Image File '/home/site/wwwroot/.python_packages/lib/site-packages/PIL/Image.py', line 103, in from . import _imaging as core

That is followed by this error:

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.).

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:

  1. Downgrade to v1 programming model
  2. Swap to a dedicated ASP rather than consumption plan

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.

Can you try adding a list of functions in that script that you want to load?

{
  "version": "2.0",
  **"functions": ["myBasicHTTPFunc", "MyOtherFunc"],**
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[4.*, 5.0.0)"
  }
}

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_module call 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:

  • missing packages/dependencies (files),
  • failing imports (code exceptions from import attempt),
  • in my case I had a module-level function call which was throwing on deployed instance but not local (because it was using an environment variable that I forgot to set on the app, but had it locally xD)

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).

Note this is not insignificant since there’s side effects. Logging via the module functions (e.g. logging.info) now doesn’t call logging.basicConfig. But logging.basicConfig wouldn’t do anything anyways, for the same reason - handler exists already - so if user was to call it, it wouldn’t do anything either. So you basically have a custom pre-configured root logger at start, that’s best way to think of IMO.

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):

import logging
_root_logger = logging.getLogger(name=None)
_root_logger_sh = logging.StreamHandler()
_root_logger.addHandler(_root_logger_sh)
app = func.FunctionApp(http_auth_level=func.AuthLevel.FUNCTION)

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>.yml you can add after you install your packages and before zipping the release:

    - name: Install dependencies
      run: pip install -r requirements.txt

    - name: Copy all package files from the virtual environment to the root directory
      run: cp -r $(python -c 'import site; print(site.getsitepackages()[0])')/* .

    - name: Zip artifact for deployment
      run: zip release.zip ./* -r

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! 😃

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:

  1. Access the SSH Web Interface: …

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.

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?

{
  "version": "2.0",
  **"functions": ["myBasicHTTPFunc", "MyOtherFunc"],**
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[4.*, 5.0.0)"
  }
}

@BillmanH I am able to run the function locally. I believe that my host.json is alright:

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[4.*, 5.0.0)"
  }
}

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:

  • changing func version
  • simply changing pyscopg to psycopg-binary in Requirements
  • Tried moving module import into function
  • etc.

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 jsonschema as a requirement, as in setup(install_requires=[<jsonschema goes here>]) in setup.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_requires on my privately published dependency.

This explains why pip freeze > ./requirements.txt solves the symptom, but obviously the real issues are that:

  1. A dependency is missing from their project, and it is likely a transitive one.
  2. Azure Functions should you and fail to build/publish when this happens.

I was able to solve this by including all dependencies my app used in my requirements.txt file. I was able to solve it with the help of @saari-oj 's comment where they only had the import azure.functions as func as the only import.

I then saw that my requirements.txt file 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.txt

I’m using the v2 model, Python (v3.10) func app.

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-deps

I’ve tested this by confirming that the functions do not trigger when running the same command with --build remote instead 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-deps flag to the .vscode/settings.json file 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.txt with the output of $ pip freeze solved 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.py file. 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 psycopg2 package, changing the requirements.txt to use psycopg2-binary fixed this issue. Retrying the v2 python worker using the psycopg2-binary package 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