Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure Function - Python -> warn: Host.Startup[0]. No job functions found. Try making your job classes and methods public. #987

Open
girguy opened this issue Nov 8, 2023 · 6 comments

Comments

@girguy
Copy link

girguy commented Nov 8, 2023

I'm currently working on a simple Azure Function that's triggered by an HTTP request. I'm trying to run it within a Docker container, but I'm facing an issue where the function doesn't seem to be recognized. Here's the warning I receive in my logs:

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

Azure function

import azure.functions as func
import logging

app = func.FunctionApp()

@app.route(route="HttpExample", auth_level=func.AuthLevel.ANONYMOUS)
def HttpExample(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')

    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
        )

Docker file

# To enable ssh & remote debugging on app service change the base image to the one below
# FROM mcr.microsoft.com/azure-functions/python:4-python3.10-appservice
FROM mcr.microsoft.com/azure-functions/python:4-python3.10

ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true

COPY requirements.txt /
RUN pip install -r /requirements.txt

COPY . /home/site/wwwroot

Here are the lines I used to build and run the docker container
docker build --tag ggirineza/azure_functions_image_test:v1.0.0 .
docker run -p 8080:80 -it ggirineza/azure_functions_image_test:v1.0.0

My experience with Docker is fairly limited, though I have successfully deployed similar functions using AWS Lambda, which was a more intuitive process for me. But with Azure, I really don't get it honestly..

I would really appreciate some help.

@ADR-007
Copy link

ADR-007 commented Nov 10, 2023

+1. I have the same problem, and already spent a lot of hours trying to run the "hello world" function in docker.

@halyssonfreitas
Copy link

Try to add: AzureWebJobsFeatureFlags=EnableWorkerIndexing

Like in exemple:

FROM mcr.microsoft.com/azure-functions/node:4-nightly-node18

ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true \
    AzureWebJobsFeatureFlags=EnableWorkerIndexing

COPY . /home/site/wwwroot

RUN cd /home/site/wwwroot && \
    npm install && \
    npm run build

@halyssonfreitas
Copy link

If you aren't using Docker, so try add "AzureWebJobsFeatureFlags": "EnableWorkerIndexing" in local.settings.json values.

@sudharsan2020
Copy link

Please install azure-functions-core-tools-4 by stepping inside the Docker container and run the below commands. The default logs doesn't provide any useful information apart from saying No job functions found

Step inside your docker container using this:

sudo docker run -it -u 0  -p 15000:80  demo:latest /bin/bash

After stepping inside the container, then run the below commands to install the azure-functions-core-tools-4

apt update 
apt install -y curl
apt install -y gnupg
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-jammy-prod jammy main" > /etc/apt/sources.list.d/dotnetdev.list'
apt-get update
apt-get install azure-functions-core-tools-4

Then navigate to the project folder and manually run func start --verbose to identify the missing dependencies in an easier way.

Hope it helps!

@jmelhus
Copy link

jmelhus commented Dec 30, 2023

Try to add: AzureWebJobsFeatureFlags=EnableWorkerIndexing

Like in exemple:

FROM mcr.microsoft.com/azure-functions/node:4-nightly-node18

ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true \
    AzureWebJobsFeatureFlags=EnableWorkerIndexing

COPY . /home/site/wwwroot

RUN cd /home/site/wwwroot && \
    npm install && \
    npm run build

this worked for me

@lopez-
Copy link

lopez- commented Feb 21, 2024

Please install azure-functions-core-tools-4 by stepping inside the Docker container and run the below commands. The default logs doesn't provide any useful information apart from saying No job functions found

Step inside your docker container using this:

sudo docker run -it -u 0  -p 15000:80  demo:latest /bin/bash

After stepping inside the container, then run the below commands to install the azure-functions-core-tools-4

apt update 
apt install -y curl
apt install -y gnupg
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-jammy-prod jammy main" > /etc/apt/sources.list.d/dotnetdev.list'
apt-get update
apt-get install azure-functions-core-tools-4

Then navigate to the project folder and manually run func start --verbose to identify the missing dependencies in an easier way.

Hope it helps!

@sudharsan2020 's suggestion did it for me. With the verbose logs I could see that the durable function's trigger was still pointing to 127.0.0.1 which doesn't resolve to azurite's container. The connection fails and the error just says "No job functions found". How I resolved it:

  • Modify local.settings.json and set the value
"DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://azurite:10000/devstoreaccount1;QueueEndpoint=http://azurite:10001/devstoreaccount1;TableEndpoint=http://azurite:10002/devstoreaccount1;"
  • Modify the entrypoint of the Docker image and start the function as below:
ENTRYPOINT [ "func", "start", "--verbose" ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants