I building an .NET Core 3.1 Azure Functions application on my local and am trying to import a .NET Core 3.1 class library into the Functions project, but when I do, I get the following error when I run the app:
Microsoft.Azure.Functions.Extensions: Method not found: 'Microsoft.Extensions.Configuration.IConfigurationBuilder Microsoft.Azure.WebJobs.Hosting.IWebJobsConfigurationBuilder.get_ConfigurationBuilder()'. Value cannot be null. (Parameter 'provider')
I am using the ConfigurationBuilder in my Functions project:
var config = new ConfigurationBuilder()
.SetBasePath(context.FunctionAppDirectory)
.AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.Build();
Then I also use the configuration in a service in my library:
public MyService(IConfiguration configuration)
{
_configuration = configuration;
}
In my Functions project I added a reference to Microsoft.Extensions.Configuration
as the error indicated that it couldn't find the ConfigurationBuilder definition.
I can import a .NET Standard 2.0 project without any errors. I read that Azure Funciton V3 is compatible with .NET Core 3.1 class libraries. I have tried downgrading Microsoft.Azure.Functions.Extensions
and played around with package versions, but nothing works.
Is what I am doing in my Functions project with Configuration incompatible with the .NET Core library? Why am I getting this error.