chmoder
chmoder

Reputation: 985

Could not load type 'System.Environment' from assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

We are updating from .NET 3.1 to .NET 6. After deploying the Azure Function App, the "Runtime version" displays, "Error", and the below message is on the overview page.

Could not load type 'System.Environment' from assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Upvotes: 12

Views: 8015

Answers (2)

Racc
Racc

Reputation: 11

Just as an addition, for anyone like me following these answers in a local development environment; ensure that your Functions Core Tools are up-to-date too. If they're not you'll see the error described in this post, even after updating your functions config. To verify, check the Runtime version when your solution starts (e.g. Function Runtime Version: 4.25.3.21264) and if necessary, update the core tools as described in the MS guidance: Develop Azure Functions locally using Core Tools

Upvotes: 0

chmoder
chmoder

Reputation: 985

The solution is to update the function app to version 4.

Updating the following project values to:

<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>

and

Using this command: az functionapp config appsettings set --settings FUNCTIONS_EXTENSION_VERSION=~4 -n <APP_NAME> -g <RESOURCE_GROUP_NAME>

source: https://learn.microsoft.com/en-us/azure/azure-functions/functions-versions?tabs=in-process%2Cv4&pivots=programming-language-csharp#migrating-from-3x-to-4x

Upvotes: 22

Related Questions