I'm currently migrating an Azure Function from v2 to Azure Functionsv4. I already migrated my project to .NET6 and fixed all the package reference errors. I have in the solution 3 projects which I adjusted to .NET6 and Azure Function v4. For that I edited the .csproj files of each of those projects and upgraded/substituted packages which are not working with .NET6. The project file of each project looks like:
Azure Function Project:
<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFramework>net6.0</TargetFramework><AzureFunctionsVersion>v4</AzureFunctionsVersion></PropertyGroup><ItemGroup><PackageReference Include="Azure.Messaging.ServiceBus" Version="7.11.1" /><PackageReference Include="Azure.Messaging.EventHubs" Version="5.7.5" /><PackageReference Include="DocumentFormat.OpenXml" Version="2.18.0" /><PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.33" /><PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventHubs" Version="5.1.2" /><PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.8.1" /><PackageReference Include="Microsoft.CSharp" Version="4.7.0" /><PackageReference Include="Microsoft.Extensions.Azure" Version="1.6.0" /><PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" /><PackageReference Include="Microsoft.Identity.Client" Version="4.48.1" /><PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.3" /></ItemGroup><ItemGroup><ProjectReference Include="..\PCM.1.z\x.1.z.csproj" /></ItemGroup><ItemGroup><Compile Update="2.cs"><CopyToOutputDirectory>Always</CopyToOutputDirectory></Compile><Compile Update="1.cs"><CopyToOutputDirectory>Always</CopyToOutputDirectory></Compile><Compile Update="3.cs"><CopyToOutputDirectory>Always</CopyToOutputDirectory></Compile></ItemGroup><ItemGroup><None Update="host.json"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></None><None Update="local.settings.json"><CopyToOutputDirectory>Always</CopyToOutputDirectory><CopyToPublishDirectory>Never</CopyToPublishDirectory></None></ItemGroup></Project>
Second Project:
<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFramework>net6.0</TargetFramework></PropertyGroup><ItemGroup><PackageReference Include="Azure.Messaging.ServiceBus" Version="7.11.1" /><PackageReference Include="Azure.Messaging.EventHubs" Version="5.7.5" /><PackageReference Include="Microsoft.ApplicationInsights" Version="2.21.0" /><PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" /><PackageReference Include="Microsoft.Azure.Devices" Version="1.38.2" /><PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.33" /><PackageReference Include="SendGrid" Version="9.28.1" /><PackageReference Include="StackExchange.Redis" Version="2.6.80" /><PackageReference Include="Twilio" Version="6.0.1" /><PackageReference Include="UnitsNet" Version="4.149.0" /></ItemGroup><ItemGroup><ProjectReference Include="..\x.1.w\x.1.w.csproj" /></ItemGroup></Project>
Third Project:
<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFramework>net6.0</TargetFramework></PropertyGroup><ItemGroup><PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0" /></ItemGroup></Project>
When I build the project I got no errors. But when I debug the project I got an exception which looks like:
Exception:
Exception thrown: 'System.IO.FileNotFoundException' in Microsoft.Azure.WebJobs.Host.dll.An exception of type 'System.IO.FileNotFoundException' occurred in Microsoft.Azure.WebJobs.Host.dll but was not handled in user codeCould not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
I have tried the last two weeks different packages since when I googled this error, the suggestion was to see which packages are not supported by package:<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.3" />
. I analyzed all my packages. After changing them back and force I got still the same error.
Can anyone help me and say what exactly I have to change?