Azure / azure-functions-docker

This repo contains the base Docker images for working with azure functions
MIT License
261 stars 117 forks source link

Docker + Azure V2 Python model issue: No job functions found #1028

Open yakutsa opened 8 months ago

yakutsa commented 8 months ago

Using M1 chip via MacBook Air, so I have to use Docker to avoid compatibility issues. I did a very small set-up via Azure functions v2 - blueprint & function - however I am facing issues with the same error despite many many attemps: no job functions found.

Here's the codes:

Dockerfile

FROM mcr.microsoft.com/azure-functions/python:4-python3.10

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

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

COPY . /home/site/wwwroot

host.json

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

blueprint.py

import azure.functions as func
import logging

bp = func.Blueprint()

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

    # Simply return a 'Hello World' message
    return func.HttpResponse(
        "Hello World",
        status_code=200
    )

function_app.py

import azure.functions as func
from blueprint import bp

app = func.FunctionApp()
app.register_functions(bp)

# Logging to confirm registration
logging.info("Functions registered successfully.")

Docker build and run successful without any log errors only with a warning message:

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

I know one solution is to use v1 as there are more documentations available and more reusable codes however that support is going to end in 2026. Is there anything I am missing to fix the above issue? If not, then I will switch it to v1.

I even tried building:

docker build --no-cache -t containername .

that also didn't work.

sudharsan2020 commented 7 months ago

Can you please try this https://github.com/Azure/azure-functions-docker/issues/987#issuecomment-1846724440 ?