On December 3, 2022, .NET Core 3.1 will be retired. As a result, Azure Functions runtime versions 2.x and 3.x, which use .NET Core 3.1, will also be retired on that date.
A function app runs on a specific version of the Azure Functions runtime. By default, function apps are nowadays created in version 4.x of the runtime. If you have developed Azure Functions in the past, probably these functions are running with runtime 2.x or 3.x.
Your Functions applications that use runtime version 2.x or 3.x will continue to run and your existing workloads won’t be affected. However, Microsoft will no longer provide updates or customer service for applications that use these versions.
The message of this post is just one: if you are using Azure Functions in your cloud solutions, in Dynamics 365 Business Central projects and generally speaking everywhere you’re using them, start update your old Function app to use runtime 4.x.
Functions runtime version 4.x includes:
- The latest security updates.
- Support for the latest programming languages such as .NET 6 and Node 16.
You can update the runtime of your function apps directly from the Azure Portal, but at the time of writing this post things are not so perfect in my opinion, so that’s why I’ve decided to write this post.
If you have an Azure Function running on Azure, you can discover the version of the runtime your function is running via Azure Portal simply by selecting the function app and clicking on the Configuration blade:
In the example above, my Azure Function app is currently running on runtime version 3.
How to update the runtime to version 4?
The runtime version of your Azure Function app is determined by the
In many scenarios, you cannot simply select runtime 4 from the above drop-down box. Runtime 4 is missing from the available choices. To update your Azure Function runtime to version 4, I suggest to use Azure CLI and execute the following command:
az functionapp config appsettings set --name <FUNCTION_APP> \ --resource-group <RESOURCE_GROUP> \ --settings FUNCTIONS_EXTENSION_VERSION=<VERSION>
where FUNCTION_APP is the name of your Azure Function, RESOURCE_GROUP is the Resource Group of your function app, VERSION is the value of the runtime version you need to set (for example ~4).
To update my function app runtime to version 4, I’ve executed the following command:
After this command, if you check your function app configuration, you will see the following:
Runtime is now set to custom (~4) and a warning is displayed:
“Your app is pinned to an unsupported runtime version for ‘dotnet’. For better performance, we recommend using one of our supported versions instead: xxx.”
If you access the Azure Resource Explorer (https://resources.azure.com/) and browse your subcription/resource grop/providers/Microsoft.Web/Sites/Your Function App/Config/web you can check the runtime stack version of your function app.
If FUNCTIONS_WORKER_RUNTIME is set to “dotnet”, check the value of “netFrameworkVersion“. If set to “powershell”, check “powerShellVersion“. Same for other programming languages.
Here you can see that my function app is runnig on .NET Framework 4 stack:
For function runtime v4, if “netFrameworkVersion” is “v4.0” or “powerShellVersion” is “~6”, those language stack versions are unsupported in V4, you’ll then see the warning message on portal and runtime got set to “custom” automatically.
Function V4 runtime requires .NET 6.0. The platform didn’t update it automatically, this is to avoid breaking customer’s applications who uses any method/type unsupported in .NET 6.0.
At the moment Microsoft is leaving this .NET version upgrade action (updating “netFrameworkVersion”) to customers, and with the warning message to remind that the function v4 will need .NET 6.0. You could then decide if the function is ready to be upgraded to v4 from older runtime version.
You can use the Azure CLI to update “netFrameworkVersion” in the app config for your function ap as follows:
az functionapp config set --net-framework-version v6.0 -n <APP_NAME> -g <RESOURCE_GROUP_NAME>
In my sample above, I executed the following command:
and now the result is the following:
Warning is disappeared and my function app is running on runtime V4.
Please remember this and act accordingly when needed.
I still can’t believe this is Microsoft’s upgrade path for Azure functions to .net 6 and runtime V4 (~4)
Having to run separate CLI command or going to Azure Resource Explorer… I really don’t get why this is necessary – especially when other Azure Resrouces you CAN just change a dropdown to .net 6 and off you go
Now the upgrade path is more easy.
If we use the WEBSITE_RUN_FROM_PACKAGE app setting to depoy your FunctionApp, the FunctionApp can’t start after updating “netFrameworkVersion”. We get there errors :
• Failed to copy zip from remote source.
• Adding virtual directory from failure zip file \\?\d:\local\SitePackages\428243046.zip
You need to deploy again the FunctionApp to fix the problem.
So, with this WEBSITE_RUN_FROM_PACKAGE app setting, what is the best method to upgrade a Function App from 3x to 4x ?