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

Closed yovelcohen closed 4 months ago

yovelcohen commented 4 months ago

Investigative information

Please provide the following:

Repro steps

Provide the steps required to reproduce the problem:
  1. func init
  2. add new HTTP/blob triggers
  3. build a docker image and run it with docker run -it --rm -e -p 8080:80 <imgtag>
  4. no functions detected in output logs.

Expected behavior

Provide a description of the expected behavior.

all functions should be discovered

Actual behavior

No Job-Functions found, but when I ran the function using func start all of the functions were recognized and working when I called them locally.

Contents of the requirements.txt file:

Provide the requirements.txt file to help us find out module-related issues.
azure-functions==1.18.0
azure-functions-durable==1.2.8

Related information

Provide any related information

My docker file:

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

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

RUN apt-get update && apt-get install -y ffmpeg gcc portaudio19-dev python-all-dev libmagic-dev ca-certificates sox && rm -rf /var/lib/apt/lists/*

COPY requirements.txt /
RUN pip install --no-cache-dir -r /requirements.txt
RUN pip install --global-option='build_ext' --global-option='-I/usr/local/include' --global-option='-L/usr/local/lib' pyaudio==0.2.14

COPY . /home/site/wwwroot

I also tried following the suggestions such as adding different combinations of environment variables in other similar issues such as: https://github.com/Azure/azure-functions-python-worker/issues/1384 https://stackoverflow.com/questions/75519932/azure-function-python-model-2-in-docker-container

The only difference for me from those is that I'm using Python 3.11 I guess?

hallvictoria commented 4 months ago

Hi @yovelcohen

I followed the repro steps listed using the provided requirements.txt and dockerfile content, but didn't have the same issue. I tried with HTTP triggers and using a Durable Functions app.

I did need to add the AzureWebJobsStorage environment variable to my Dockerfile. Can you try adding that and see if that fixes the issue?

ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true \
    AzureWebJobsFeatureFlags=EnableWorkerIndexing  \
    AzureWebJobsStorage=...
microsoft-github-policy-service[bot] commented 4 months ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.