Func Init Python V2 Docker
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.
FYI the feature flag was removed in https://github.com/Azure/azure-functions-host/issues/8847 and changes are rolling out very soon
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)
is this still not working by default?
Maybe this isn't the place but I still can't get v2 to work at all in containers even with the AzureWebJobsFeatureFlags=EnableWorkerIndexing
@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.
@matferrari-msft is that this? AzureWebJobsStorage=UseDevelopmentStorage=true. If so, it still doesn't work. I'm just gonna use v1...
@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?
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
running into the same issue with python v2 in docker. can't get the functions to load
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"
I followed the suggested solutions, but still the functions don't get recognize, any other ideas?
I tried with http trigger it was okay, but when I add blob trigger, it was not found.
I have the same problem:
Same problem here using the v2 programming model, functions do not get recognized. Any comments from the maintainers (@matferrari-msft) on this? It's really frustrating since it is mentioned as a feature that we can use custom containers.
I am using blueprints and have one "function_app.py" file where all come together, e.g.
import azure.functions as func
from src.functions.login_token_function import bp
from src.functions.users_jobs import uj
from src.functions.login_function import login_func
from src.functions.update_jobs import update_jobs_bp
from src.functions.new_job import new_jobs_bp
from src.functions.upload_pdf import up
from src.functions.create_pdf import gpdf
app = func.FunctionApp()
app.register_functions(bp)
app.register_functions(uj)
app.register_functions(login_func)
app.register_functions(update_jobs_bp)
app.register_functions(new_jobs_bp)
app.register_functions(up)
app.register_functions(gpdf)
This works fine without a custom container.