Azure functions not working inside docker

Chirantan Datta 25 Reputation points
2024-06-24T06:19:44.42+00:00

I created one azure function using the following command:

func init --worker-runtime python --docker
func new --name HttpExample --template 

Then I created a docker image using the following dockerfile:

FROM mcr.microsoft.com/azure-functions/python

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

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

COPY . /home/site/wwwroot

The simple azure function is working locally using func start and also working inside docker image

But after that I used another application using azure function where I imported various libraries. That application is working fine locally using func start but it is not working inside docker image. At http://localhost:8080/api/HttpExample,I got error that no web page found and in the console I got a warning that no job functions found.

What things need to be done to make the azure function work inside docker image?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,950 questions
0 comments No comments
{count} vote

Accepted answer
  1. Pinaki Ghatak 4,210 Reputation points Microsoft Employee
    2024-06-28T20:12:33.44+00:00

    Hello @Chirantan Datta

    Here are a few things you can check:

    1. Make sure that you have included all the necessary dependencies in your Docker image. You can check this by running the following command inside your Docker container: pip freeze This will show you a list of all the installed Python packages. Make sure that all the packages required by your Azure Function are included in this list.
    2. Check if your Docker container is running on the correct port. By default, Azure Functions run on port 80. Make sure that your Docker container is also running on port 80. You can specify the port using the -p option when running the docker run command.
    3. Check if your Azure Function is being triggered correctly. Make sure that the function is being triggered by the correct HTTP endpoint. You can check this by running the following command inside your Docker container: func azure functionapp list-functions. This will show you a list of all the functions in your Azure Function app. Make sure that the function you are trying to trigger is listed here.
    4. Check if your Docker container is able to connect to the Azure Function app. Make sure that your Docker container is able to connect to the internet and that it is able to connect to the Azure Function app. You can check this by running the following command inside your Docker container: ping .azurewebsites.net This will show you if your Docker container is able to connect to the Azure Function app.

    I hope that this response has addressed your query and helped you overcome your challenges. If so, please mark this response as Answered. This will not only acknowledge our efforts, but also assist other community members who may be looking for similar solutions.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.