I have been working on to upgrade my function app .netcore3.1 solution to .net6.0. After upgrading the solution and all the packages - when i run the solution in local - it is throwing below error. I am unable to debug the function app in local. It is throwing error in startup.cs class. Any solution for this ?
System.MissingMethodException: 'Method not found: 'Microsoft.Extensions.Configuration.IConfigurationBuilder Microsoft.Azure.WebJobs.Hosting.IWebJobsConfigurationBuilder.get_ConfigurationBuilder()'.'
CodePudding user response:
I have created a Function App with.NET core 3.1
version.
My .csproj for .NET Core 3.1
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.1.1" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Migrated from .net core 3.1
to .net 6.0
, when I tried with the .csproj
provided in the code got the below errors.
In .csproj
file, Change the AzureFunctionsVersion
from v3
to v4
.
Update Microsoft.NET.Sdk.Functions
NuGet Package to latest version - 4.1.1
Output:
Code for FunctionsStartup in Startup.cs
using Function3Core;
using Microsoft.Azure.WebJobs.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
[assembly: FunctionsStartup(typeof(Startup))]
namespace Function3Core
{
class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
}
}
}
Code for WebJobsStartup in Startup.cs
using Function3Core;
using Microsoft.Azure.WebJobs.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
[assembly: WebJobsStartup(typeof(Startup))]
namespace Function3Core
{
class Startup : IWebJobsStartup
{
public void Configure(IWebJobsBuilder builder)
{
}
}
}