Skip to content

Building functions base images on demand

Bala G edited this page Sep 23, 2021 · 1 revision

Custom functions images are built on top of functions base images built and published by Functions team. Instructions to build and use custom images are available here. These base images get updated once every 2 weeks and pushed to the same tag.

For example, If you were building a custom image on top of Functions V3 python 3.9 base image, the base image you would use in your Dockerfile is mcr.microsoft.com/azure-functions/python:3.0-python3.9

Once every 2 weeks, the image behind the tag (mcr.microsoft.com/azure-functions/python:3.0-python3.9) will get updated automatically. To incorporate these updates in your custom image, you would have rebuild your dockerfile which will pull the latest version of mcr.microsoft.com/azure-functions/python:3.0-python3.9.

If for some reason, you would like to get updates to the published base images more frequently, you can build the base image manually as well (and then base your custom image on top of that manually built image)

Taking Functions V3, Python 3.9 as an example

Your initial Dockerfile would look like

FROM mcr.microsoft.com/azure-functions/python:3.0-python3.9

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

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

COPY . /home/site/wwwroot

<Rest of the Docker file>

The dockerfiles used to build the base functions images are available at https://github.com/Azure/azure-functions-docker/tree/dev/host In this case, the file we are interested in is https://github.com/Azure/azure-functions-docker/blob/dev/host/3.0/buster/amd64/python/python39/python39.Dockerfile

Use the below instructions to rebuild this image on demand:

Clone the repo and run the following command

cd \azure-functions-docker\host\3.0\buster\amd64\python\python39>

docker build --no-cache -t local/3.0-python3.9 -f python39.Dockerfile .

This will build a local updated version of the image mcr.microsoft.com/azure-functions/python:3.0-python3.9 with the tag local/3.0-python3.9

Make the below change to your Dockerfile

FROM mcr.microsoft.com/azure-functions/python:3.0-python3.9

to

FROM local/3.0-python3.9

and rebuild the custom image and configure your functionapp to start using this image.