0

I am deploying an Azure Function via Terraform as a docker image and using the mcr.microsoft.com/azure-functions/python:4-python3.9-slim image as base.

I found no explanation on why the runtime version is still custom (~4) as seen on the image below.
[Configuration page, Function runtime settings]

enter image description here

I tried to specify the following App Setting for the Function App:
FUNCTIONS_WORKER_RUNTIME = "python"

This does not change anything, the function works with or without this setting.

Based on all the Microsoft documentation, there is no evidence why it shows custom (~4) instead of ~4 .

Is it completely normal because of the docker image or is some configuration missing?

1 Answers1

0

Based on all the Microsoft documentation, there is no evidence why it shows custom (~4) instead of ~4 .

The Azure Function Image mcr.microsoft.com/azure-functions/python:4-python3.9-slim states that the Python 3.9 Version with Azure Functions Core Tools Version 4:

enter image description here

As given in this Terraform Official Doc of Azure Functions Python, you have to specify the FUNCTIONS_WORKER_RUNTIME to python:

app_settings {
    FUNCTIONS_WORKER_RUNTIME = "python"
  }

When you deploy the base image of Python docker Azure Functions to the Azure Function App in the Cloud, then the Function Worker Runtime will be set to Python if specified in the Terraform Code:

enter image description here

Azure Portal shows custom (~4) for Runtime version in both cases.

If you have specified the version = "~4" under function app resource in the terraform code, then the function runtime version is set to 4 in the Azure portal, given in the Same Terraform doc given above.

Even Python 3.9 version is supported in both V4 and V3 of Azure Functions Core Tools as mentioned in this MS Doc, you have used the Version 4 of Python 3.9 Azure Functions. So, the Runtime version is Application Settings Configuration Menu is set to 4.

Refer to this MCR Doc for list of the Supported Python Version in Azure Functions - Docker Context to the Azure Functions Core tools Version

  • After deploying an image with base `python:4-python3.9-slim` or `python:3.0-python3.8`, the `FUNCTIONS_WORKER_RUNTIME` setting is not set to `python` automatically for me, unless I specify it as an app setting in Terraform (but everything still works without it) and the strange thing is that Azure Portal shows `custom (~4)` for Runtime version in both cases! – András Czinege Jan 27 '23 at 08:25
  • Yes @AndrásCzinege, You have to specify the `FUNCTIONS_WORKER_RUNTIME` under application settings in terraform code and also you have specified the function runtime version under the function app resource as `version = "~4"` which should be specified in the terraform code for which version of Azure Functions Runtime to use. I have updated my answer –  Jan 27 '23 at 08:34
  • I am using the [azurerm_linux_function_app](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_function_app#docker) (since the resource you have linked will be deprecated soon), where I have configured my docker image (that is built on `python:4-python3.9-slim` or `python:3.0-python3.8` using application stack --> docker. The Terraform doc states that if the application stack block is set, there must not be an application setting FUNCTIONS_WORKER_RUNTIME. – András Czinege Jan 27 '23 at 09:38
  • Now I am confused whether I should set the `python_version` along with the docker block in application_stack or not, since the python version is defined in the my image already. – András Czinege Jan 27 '23 at 09:38
  • Pretty Simple that you have to specify the Function Runtime Version as 4, Functions Worker Runtime as Python and Python Version to 3.9 as `site_config { linux_fx_version = "python|3.9" }` –  Jan 27 '23 at 10:30
  • There is the terraform sample code provided by Hashicorp for Azure Functions Python Linux Version - [Source Link](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/function_app#example-usage-python-in-a-consumption-plan) where it explains all the required settings to be configured. –  Jan 27 '23 at 10:33
  • 1
    But I am not using the resource that you have sent an example of (azurerm_function_app ), because it is going to be removed soon, I am using the azurerm_linux_function_app resource, which has different settings. With this one, the functions_extension_version can be used to set the runtime version (which defaults to ~4), and I have set my docker image using application stack --> docker. And what I don't understand is whether I have to specify the python_version as well in the application stack, because I already have docker there with an image built using python:4-python3.9-slim. – András Czinege Jan 27 '23 at 11:02
  • Okay. Even the [Link](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_function_app#docker) you have provided, the section `stie_config` is available to specify the python version and it is mentioned as that parameter (python version) specifying is optional in the same document. –  Jan 27 '23 at 11:12