How to deploy an Ubuntu-based Docker container in Azure Functions?

Sachitha Abeydeera 20 Reputation points
2025-01-15T08:16:39.6833333+00:00

I have developed an Azure Durable Function with an HTTP trigger. Based on the latest requirements, I need to use Docker to accommodate the changes. Therefore, I will be using the ubuntu:22.04 Docker image.

Here is the Docker image I am using:

FROM ubuntu:22.04
RUN apt update && apt install -y python3.11
RUN echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections
RUN apt install -y ttf-mscorefonts-installer
RUN apt install -y python3-pip
RUN apt install -y wget
RUN python3.11 -m pip install pillow
RUN python3.11 -m pip install --upgrade pip
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 2
RUN update-alternatives --auto python3
RUN wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb
RUN dpkg -i ./libssl1.1_1.1.0g-2ubuntu4_amd64.deb
RUN rm -i libssl1.1_1.1.0g-2ubuntu4_amd64.deb
RUN wget -q https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb
RUN dpkg -i packages-microsoft-prod.deb
RUN apt update
RUN apt install azure-functions-core-tools-4
RUN rm -i packages-microsoft-prod.deb

RUN apt-get update && apt-get install -y curl apt-transport-https lsb-release gnupg

# Install Azure CLI
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash

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

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

COPY . /home/site/wwwroot
WORKDIR /home/site/wwwroot

CMD ["func", "host", "start"]


It works fine when I run the Docker container locally. However, when I deploy it to Azure Functions, the function app fails to start, even though the container is running without issues. The error indicates a health check issue.

User's image

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,595 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Pinaki Ghatak 5,575 Reputation points Microsoft Employee
    2025-01-15T09:23:27.88+00:00

    Hello @Sachitha Abeydeera

    To deploy an Ubuntu-based Docker container in Azure Functions, you can follow the steps below:

    1. Create a Dockerfile with the necessary dependencies and configurations. You have already done this step.
    2. Build the Docker image locally using the following command: docker build -t .
    3. Test the Docker image locally using the following command: docker run -p 8080:80 This command maps port 80 in the container to port 8080 on your local machine.
    4. Push the Docker image to a container registry such as Docker Hub or Azure Container Registry.
    5. Create an Azure Function app with a custom container using the Azure CLI or Azure portal.
    6. In the Azure portal, go to the Function app's Configuration settings and add an app setting with the key WEBSITES_PORT and the value 80.
    7. In the Azure portal, go to the Function app's Container settings and configure the container settings as follows:
      • Image source: Select the container registry where you pushed the Docker image.
      • Image and tag: Enter the name of the Docker image and the tag you want to use.
      • Startup command: Enter the command to start the function app. In your case, it should be func host start.
    8. Save the container settings and restart the Function app. Regarding the error you are facing, it seems to be related to the health check configuration.

    You can try disabling the health check by adding the following app setting to your Function app: WEBSITE_HEALTHCHECK_PATH = ""

    This should disable the health check and allow your Function app to start.


    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.


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.