Skip to content

Latest commit

 

History

History
188 lines (125 loc) · 11.6 KB

set-runtime-version.md

File metadata and controls

188 lines (125 loc) · 11.6 KB
title description ms.service ms.topic ms.date ms.custom zone_pivot_groups
How to target Azure Functions runtime versions
Learn how to specify the runtime version of a function app hosted in Azure.
azure-functions
how-to
07/03/2024
ignite-2023, linux-related-content
app-service-platform-windows-linux

How to target Azure Functions runtime versions

A function app runs on a specific version of the Azure Functions runtime. By default, function apps are created in the latest 4.x version of the Functions runtime. Your function apps are supported only when they run on a supported major version. This article explains how to configure a function app in Azure to target, or pin to, a specific version when required.

::: zone pivot="platform-windows" The way that you target a specific version depends on whether you're running Windows or Linux. This version of the article supports Windows. Choose your operating system at the top of the article. ::: zone-end ::: zone pivot="platform-linux" The way that you target a specific version depends on whether you're running Windows or Linux. This version of the article supports Linux. Choose your operating system at the top of the article. ::: zone-end

Important

When possible, always run your functions on the latest supported version of the Azure Functions runtime. You should only pin your app to a specific version if you're instructed to do so due to an issue with the latest version. Always move up to the latest runtime version as soon as your functions can run correctly.

During local development, your installed version of Azure Functions Core Tools must match the major runtime version used by the function app in Azure. For more information, see Core Tools versions.

Update your runtime version

When possible, you should always run your function apps on the latest supported version of the Azure Functions runtime. If your function app is currently running on an older version of the runtime, you should migrate your app to version 4.x

[!INCLUDE functions-migrate-apps]

To determine your current runtime version, see View the current runtime version.

View the current runtime version

You can view the current runtime version of your function app in one of these ways:

[!INCLUDE Set the runtime version in the portal]

You can view the FUNCTIONS_EXTENSION_VERSION app setting from the Azure CLI.

Using the Azure CLI, view the current runtime version with the az functionapp config appsettings list command:

az functionapp config appsettings list --name <function_app> \
--resource-group <my_resource_group>

In this code, replace <function_app> with the name of your function app. Also replace <my_resource_group> with the name of the resource group for your function app.

You see the FUNCTIONS_EXTENSION_VERSION in the following partial output:

[
  {
    "name": "FUNCTIONS_EXTENSION_VERSION",
    "slotSetting": false,
    "value": "~4"
  },
  {
    "name": "FUNCTIONS_WORKER_RUNTIME",
    "slotSetting": false,
    "value": "dotnet"
  },
  
  ...
]

Choose Open Cloud Shell in the previous code example to run the command in Azure Cloud Shell. You can also run the Azure CLI locally to execute this command. When running locally, you must first run az login to sign in.

To check the Azure Functions runtime, use the following cmdlet:

Get-AzFunctionAppSetting -Name "<FUNCTION_APP>" -ResourceGroupName "<RESOURCE_GROUP>"

Replace <FUNCTION_APP> with the name of your function app and <RESOURCE_GROUP>. The current value of the FUNCTIONS_EXTENSION_VERSION setting is returned in the hash table.


Pin to a specific version

Azure Functions lets you use the FUNCTIONS_EXTENSION_VERSION app setting to target the runtime version used by a given function app. If you specify only the major version (~4), the function app is automatically updated to new minor versions of the runtime as they become available. Minor version updates are done automatically because new minor versions aren't likely to introduce changes that would break your functions. ::: zone pivot="platform-linux" Linux apps use the linuxFxVersion site setting along with FUNCTIONS_EXTENSION_VERSION to determine the correct Linux base image in which to run your functions. When you create a new function app on Linux, the runtime automatically chooses the correct base image for you based on the runtime version of your language stack. ::: zone-end Pinning to a specific runtime version causes your function app to restart. ::: zone pivot="platform-windows" When you specify a specific minor version (such as 4.0.12345) in FUNCTIONS_EXTENSION_VERSION, the function app is pinned to that specific version of the runtime until you explicitly choose to move back to automatic version updates. You should only pin to a specific minor version long enough to resolve any issues with your function app that prevent you from targeting the major version. Older minor versions are regularly removed from the production environment. When your function app is pinned to a minor version that is later removed, your function app is instead run on the closest existing version instead of the version set in FUNCTIONS_EXTENSION_VERSION. Minor version removals are announced in App Service announcements.

Note

When you try to publish from Visual Studio to an app that is pinned to a specific minor version of the runtime, a dialog prompts you to update to the latest version or cancel the publish. To avoid this check when you must use a specific minor version, add the <DisableFunctionExtensionVersionUpdate>true</DisableFunctionExtensionVersionUpdate> property in your .csproj file.

Use one of these methods to temporarily pin your app to a specific version of the runtime:

[!INCLUDE Set the runtime version in the portal]

  1. To pin your app to a specific minor version, in the left pane, expand Settings, and then select Environment variables.

  2. From the App settings tab, select FUNCTIONS_EXTENSION_VERSION, change Value to your required minor version, and then select Apply.

  3. Select Apply, and then select Confirm to apply the changes and restart the app.

You can update the FUNCTIONS_EXTENSION_VERSION app setting in the function app with the az functionapp config appsettings set command.

az functionapp config appsettings set --name <FUNCTION_APP> \
--resource-group <RESOURCE_GROUP> \
--settings FUNCTIONS_EXTENSION_VERSION=<VERSION>

Replace <FUNCTION_APP> with the name of your function app and <RESOURCE_GROUP> with the name of the resource group for your function app. Also, replace <VERSION> with the specific minor version you temporarily need to target.

Choose Open Cloud Shell in the previous code example to run the command in Azure Cloud Shell. You can also run the Azure CLI locally to execute this command. When running locally, you must first run az login to sign in.

Use this script to pin the Functions runtime:

Update-AzFunctionAppSetting -Name "<FUNCTION_APP>" -ResourceGroupName "<RESOURCE_GROUP>" -AppSetting @{"FUNCTIONS_EXTENSION_VERSION" = "<VERSION>"} -Force

Replace <FUNCTION_APP> with the name of your function app and <RESOURCE_GROUP> with the name of the resource group for your function app. Also, replace <VERSION> with the specific minor version you temporarily need to target. You can verify the updated value of the FUNCTIONS_EXTENSION_VERSION setting in the returned hash table.


The function app restarts after the change is made to the application setting. ::: zone-end ::: zone pivot="platform-linux" To pin your function app to a specific runtime version on Linux, you set a version-specific base image URL in the linuxFxVersion site setting in the format DOCKER|<PINNED_VERSION_IMAGE_URI>.

Important

Pinned function apps on Linux don't receive regular security and host functionality updates. Unless recommended by a support professional, use the FUNCTIONS_EXTENSION_VERSION setting and a standard linuxFxVersion value for your language and version, such as Python|3.9. For valid values, see the linuxFxVersion reference article.

Pinning to a specific runtime isn't currently supported for Linux function apps running in a Consumption plan.

The following example shows the linuxFxVersion value required to pin a Node.js 16 function app to a specific runtime version of 4.14.0.3:

DOCKER|mcr.microsoft.com/azure-functions/node:4.14.0.3-node16

When needed, a support professional can provide you with a valid base image URI for your application.

Use the following Azure CLI commands to view and set the linuxFxVersion. You can't currently set linuxFxVersion in the portal or by using Azure PowerShell:

  • To view the current runtime version, use the az functionapp config show command:

    az functionapp config show --name <function_app> \
    --resource-group <my_resource_group> --query 'linuxFxVersion' -o tsv
    

    In this code, replace <function_app> with the name of your function app. Also, replace <my_resource_group> with the name of the resource group for your function app. The current value of linuxFxVersion is returned.

  • To update the linuxFxVersion setting in the function app, use the az functionapp config set command:

    az functionapp config set --name <FUNCTION_APP> \
    --resource-group <RESOURCE_GROUP> \
    --linux-fx-version <LINUX_FX_VERSION>
    

    Replace <FUNCTION_APP> with the name of your function app. Also, replace <RESOURCE_GROUP> with the name of the resource group for your function app. Finally, replace <LINUX_FX_VERSION> with the value of a specific image provided to you by a support professional.

You can run these commands from the Azure Cloud Shell by choosing Open Cloud Shell in the preceding code examples. You can also use the Azure CLI locally to execute this command after executing az login to sign in.

The function app restarts after the change is made to the site config. ::: zone-end

Next steps

[!div class="nextstepaction"] Release notes for runtime versions