This Azure Function App issue will probably be more familiar in the following months since, on December 3, 2022, .NET Core 3.1 will be retired. As a result of that, Azure Functions runtime versions 2.x and 3.x, which use .NET Core 3.1, will also be retired on that date. So, during the following months, if you are not already done or doing this, it will be extremely important to migrate all your Azure Functions to .NET 6.0, which uses runtime 4.x.
That means that you not only have the need to update your Azure Functions to .NET 6.0 on your solutions, but you also need to update your existing Function apps (using the runtime versions 2.x and 3.x) to start using the runtime 4.x.
You can check the runtime version that your Function App is using by is:
- Access your Azure Function App on the Azure Portal (https://portal.azure.com/)
- On the Azure Function App page, under Settings, select the option Configuration, and then on the top menu, select the tab Function runtime settings.
- The version which is running is presented on the Runtime version property.
Unfortunately, at least for now, we cannot upgrade it to ~4 direct from the Portal, or at least easily, simply, and direct way. And while trying to upgrade one of their Function Apps, one of my clients contacted me saying that they were now seeing a strange warning on the Function runtime settings.
Your app is pinned to an unsupported runtime version for ‘dotnet’. For better performance, we recommend using one of our supported versions instead: ~3.
Strangely we were also seeing the runtime version to be custom (~4).
Runtime version ~3 normally runs on top of .NET Framework v4.0. However, runtime version ~4 requires .NET Framework v6.0.
If you are seeing this warning or a similar warning, that means that you define a runtime version that is using an unsupported version of the .NET Framework. In this case, we define the runtime version ~4 but behind the scenes, it was still using the .NET Framework v4.0.
How you can validate which .NET Framework is defined?
You can’t easily know that information directly from the Azure Portal, but you can access the Azure Resource Explorer (https://resources.azure.com/):
- browse your subscriptions > your subscription name> resourceGroups > your resource group name > providers > Microsoft.Web > sites > Your Function App name > config > web
- Check the netFrameworkVersion property
The solution is quite simple, we need to define the runtime ~4 to use the .NET Framework v6.0.
But before that, let’s first see how we can upgrade the runtime
How to upgrade the runtime to version 4?
You can do it from the Azure Portal by:
- On the Azure Function App page, under Settings, select Configuration.
- Click/Edit the FUNCTIONS_EXTENSION_VERSION setting and change the value from ~3 to ~4
- Click OK.
Or you can execute the following Azure CLI command:
az functionapp config appsettings set --name <function-app-name> --resource-group <resource-group-name> --settings FUNCTIONS_EXTENSION_VERSION=~4
How to upgrade the .NET Framework version to version v6.0?
Finally, and actually to solve the initial issue reported, to upgrade the .NET Framework version we can:
- Access the Azure Resource Explorer (https://resources.azure.com/)
- Browse your subscriptions > your subscription name> resourceGroups > your resource group name > providers > Microsoft.Web > sites > Your Function App name > config > web
- On the top menu click Edit.
- Change the value of the netFrameworkVersion property to v6.0
- On the top menu, make sure you select the option Read/Write and then click on PATCH.
In the end, a success message will be presented, and if you check on the Azure Portal, the issue is no longer present:
Of course, you can also execute the following Azure CLI command to archive the same result:
az functionapp config set --net-framework-version v6.0 -n <function-app-name> -g <resource-group-name>