Azure / azure-functions-python-worker

Python worker for Azure Functions.
http://aka.ms/azurefunctions
MIT License
331 stars 100 forks source link

[BUG] Azure-Docker is not finding any Functions #1384

Closed Fellow-Bennse closed 6 months ago

Fellow-Bennse commented 6 months ago

Investigative information

Please provide the following:

Repro steps

Provide the steps required to reproduce the problem:
  1. Initiate new Azure-Function (func init)

  2. Add new HTTP function from HTTPExample Template

  3. Build Docker with: mcr.microsoft.com/azure-functions/python:4-python3.10 image from default Dockerfile created with func init --docker

  4. See in Log that no Job Functions were found.

Expected behavior

Provide a description of the expected behavior.

It should find a HTTP Function

Actual behavior

Provide a description of the actual behavior observed.

No Job-Functions found

(When starting it locally with "func start" it works totally fine, also works in a Docker when running "func start" in the Docker after installing the needed Command-Set)

Contents of the requirements.txt file:

Provide the requirements.txt file to help us find out module related issues.

(None needed in theory as I noticed. Issue comes up with and without requirements) azure-core==1.29.6 azure-functions==1.17.0

Related information

Provide any related information
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
        )
FellowFellow commented 6 months ago

Hi coworker of @Fellow-Bennse here.

This is the dockerfile we are currently working with.

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

RUN pip install azure-core==1.29.6 azure-functions==1.17.0

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

COPY . /azure-functions-host 
pdthummar commented 6 months ago

Hi @Fellow-Bennse and @FellowFellow, Please utilize the provided Dockerfile to address the issue. I am closing current issue as it appears to be resolved after replication. If you encounter any further issues, kindly create a new one. Thank you.

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

RUN pip install azure-core==1.29.6 azure-functions==1.17.0

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

COPY . /home/site/wwwroot
yovelcohen commented 6 months ago

@pdthummar I encounter the same error with the following Dockerfile

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

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

RUN apt-get update && apt-get install -y ffmpeg gcc portaudio19-dev

COPY . /home/site/wwwroot

RUN cd /home/site/wwwroot && pip install -r requirements.txt
pdthummar commented 6 months ago

@yovelcohen If you are using Python V2 programming model, try to add below env variable in docker file and test. If you are still facing issue, i would suggest creating a new GH issue and we will look into it. Thanks

ENV AzureWebJobsFeatureFlags=EnableWorkerIndexing

yovelcohen commented 4 months ago

@pdthummar I've tried your suggestion but it didn't work. So I opened a new ticket https://github.com/Azure/azure-functions-python-worker/issues/1424#issue-2122248771