I wanted to upgrade an Azure Function app from .NET 6 to .NET 8 and the FunctionApp version is 4.
The steps I followed was to upgrade Visual Studio to 17.9 and then changed target framework to net8.0
. After cleaning and building I am getting this error:
System.Private.Corelib: Exception while executing function:: Could not load file or assembly ‘System.Data.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=’". The system cannot find the file specified.
My project is not using System.Data.Common
. I even tried installing it explicitly it isn’t working. It is showing as .NET 8 in properties as well.
How can I fix this?
Here is the libraries and their versions used in the .csproj
file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure. Identity" Version="1.6.0" />
<PackageReference Include="Azure.Security. KeyVault.Secrets" Version="4.3.0" /> <PackageReference Include="Microsoft.Azure. KeyVault" Version="3.0.5" />
<PackageReference Include="Microsoft.Azure. Services. AppAuthentication" Version="1.6.2" /> <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.1" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
2
Answers
The type of model I was using was in-process model but as of now .NET8 supports only isolated worker process model. So I followed the steps mentioned in this documentation Migrate .NET apps from the in-process model to the isolated worker model
and it worked fine.
I have faced similar issue while upgrading .Net 6 to .Net 8:
I do agree @sigma and I solved the issue by changing the azure function to isolated function as In Process is not supported with .Net 8 :
I am using http trigger and changed it as below:
Output: