2 min read

Upgrade Azure Function app runtime version

If you are using Azure Functions with the .NET 7 isolated runtime, you may have seen the following alert in the Azure portal:

Upgrade your app to newer version as .NET 7 Isolated will reach EOL on 5/13/2024 and will no longer be supported.

This post will cover how to upgrade the .NET runtime to version 8 and resolve this issue. The .NET 8 comes with LTS support, which means Microsoft will support it until November 10, 2026.

Project configuration

First, open the project file (csproj) and set the TargetFramework to net8.0.

<TargetFramework>net8.0</TargetFramework>

Next, update the Microsoft.Azure.Functions.Worker and Microsoft.Azure.Functions.Worker.Sdk package references. You should do this for the Microsoft.Azure.Functions.Worker.Extensions packages as well.

<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.21.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.16.3" />

Visual Studio Code configuration

Open then settings.json file and update the deploySubpath value with the net8.0 path.

{
    "azureFunctions.deploySubpath": "bin/Release/net8.0/publish",
    "azureFunctions.projectLanguage": "C#",
    "azureFunctions.projectRuntime": "~4",
    "debug.internalConsoleOptions": "neverOpen",
    "azureFunctions.preDeployTask": "publish (functions)"
}

In the tasks.json file, search for the task with type equal to func and update the cwd value with the net8.0 path.

{
  "type": "func",
  "dependsOn": "build (functions)",
  "options": {
      "cwd": "${workspaceFolder}/bin/Debug/net8.0"
  },
  "command": "host start",
  "isBackground": true,
  "problemMatcher": "$func-dotnet-watch"
}

And with that, it will be possible to deploy the project using .NET 8. You may need to update other project libraries (entity framework, for example).

Azure Function

Finally, using the azure cli, configure the Azure Function app to use the .NET 8 runtime.

Remember to deploy the Azure Function app using the .NET 8 runtime version

Use the following command if the function is running on Linux operating system:

RESOURCE_GROUP=myResourceGroup
FUNCTION_APP_NAME=myFunctionApp
az functionapp config set \
  --resource-group $RESOURCE_GROUP \
  --name $FUNCTION_APP_NAME \
  --linux-fx-version "DOTNET-ISOLATED|8.0"

Or the following command if the function is running on Windows operating system:

$RESOURCE_GROUP="myResourceGroup"
$FUNCTION_APP_NAME="myFunctionApp"
az functionapp config set --resource-group $RESOURCE_GROUP --name $FUNCTION_APP_NAME  --net-framework-version "v8"

And with that, the Azure portal alert should disappear. 😊

You can click on the following link to know more about Azure Functions language runtime support policy.

Azure Functions language runtime support policy
Learn about Azure Functions language runtime support policy