Azure / azure-functions-core-tools

Command line tools for Azure Functions
MIT License
1.32k stars 434 forks source link

Func Init Python V2 Docker #3275

Open matferrari-msft opened 1 year ago

matferrari-msft commented 1 year ago

The command func init --worker-runtime python -m V2 --docker generates a Dockerfile without the env variable AzureWebJobsFeatureFlags=EnableWorkerIndexing. This prevents the function from being indexed/run inside the container.

ejizba commented 1 year ago

FYI the feature flag was removed in https://github.com/Azure/azure-functions-host/issues/8847 and changes are rolling out very soon

MRuecklCC commented 1 year ago

I just posted the following question on SO:

https://stackoverflow.com/questions/75519932/azure-function-python-model-2-in-docker-container

I think I ran into the exact same problem. (func --version = 4.0.4895)

fernandodelacalle commented 1 year ago

is this still not working by default?

jellis18 commented 1 year ago

Maybe this isn't the place but I still can't get v2 to work at all in containers even with the AzureWebJobsFeatureFlags=EnableWorkerIndexing

matferrari-msft commented 1 year ago

@jellis18 If I remember correctly, you also need to add an env variable for the storage backend the runtime uses. I believe I used the emulator.

jellis18 commented 1 year ago

@matferrari-msft is that this? AzureWebJobsStorage=UseDevelopmentStorage=true. If so, it still doesn't work. I'm just gonna use v1...

matferrari-msft commented 1 year ago

@jellis18 Yes, however, you would need to ensure that the emulator is actually accessible from within the container where the runtime is running. A potentially easier way is to just use a connection string. @ejizba @gavin-aguiar Are you able to provide any insights/guidance?

flavian-anselmo commented 1 year ago

Mine worked a after I added the following lines in my docker file

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

ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true \
    AzureWebJobsFeatureFlags=EnableWorkerIndexing \  # added by me 
    AzureWebJobsStorage='Add your conection string' #added by me 

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

COPY . /home/site/wwwroot

docker run -it --rm -p 8080:80 image_name

litan1106 commented 1 year ago

running into the same issue with python v2 in docker. can't get the functions to load image

montaro commented 11 months ago

Thanks @MRuecklCC for the SO posted Q, this is what worked for me to start the docker container locally

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

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

These 2 lines are manually added

AzureWebJobsFeatureFlags=EnableWorkerIndexing \
AzureWebJobsStorage="UseDevelopmentStorage=true"
yovelcohen commented 8 months ago

I followed the suggested solutions, but still the functions don't get recognize, any other ideas?

musitafa0032 commented 7 months ago

I tried with http trigger it was okay, but when I add blob trigger, it was not found.

santisossa commented 2 months ago

I have the same problem:

image