Azure / azure-functions-dotnet-worker-preview

MIT License
65 stars 19 forks source link

Method not found: 'Microsoft.Extensions.Configuration.IConfigurationBuilder Microsoft.Azure.WebJobs.Hosting.IWebJobsConfigurationBuilder.get_ConfigurationBuilder() '. #19

Closed machekku closed 3 years ago

machekku commented 3 years ago

Hello, When I add Microsoft.Extensions.Configuration.Json v5.0.0 to this sample project, I get Method not found: 'Microsoft.Extensions.Configuration.IConfigurationBuilder Microsoft.Azure.WebJobs.Hosting.IWebJobsConfigurationBuilder.get_ConfigurationBuilder()'.

I found this while trying to produce small reproducible code of my real problem in a larger project, where I get this error after referencing another project that has many dependencies: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

I guess this is another instance of https://github.com/Azure/azure-functions-dotnet-worker-preview/issues/13 problem.

anthonychu commented 3 years ago

@machekku Can you please share a sample app that reproduces this behavior?

machekku commented 3 years ago

@anthonychu Please see here: https://github.com/machekku/azure-functions-dotnet-worker-preview/tree/issue-19

FunctionApp>func.exe host start Microsoft (R) Build Engine version 16.8.0+126527ff1 for .NET Copyright (C) Microsoft Corporation. All rights reserved.

Determining projects to restore... All projects are up-to-date for restore. FunctionApp -> (...)\azure-functions-dotnet-worker-preview\FunctionApp\bin\output\FunctionApp.dll

Build succeeded. 0 Warning(s) 0 Error(s)

Time Elapsed 00:00:11.72

Azure Functions Core Tools Core Tools Version: 3.0.3160 Commit hash: 00aa7f43cc5c5f15241b5e6e5363256f19ceb990 Function Runtime Version: 3.0.14916.0

[2020-12-16T08:56:36.064Z] A host error has occurred during startup operation '615a5c19-af24-4708-8404-a5b781a98031'. [2020-12-16T08:56:36.067Z] FunctionApp: Method not found: 'Microsoft.Extensions.Configuration.IConfigurationBuilder Microsoft.Azure.WebJobs.Hosting.IWebJobsConfigurationBuilder.get_ConfigurationBuilder()'. Value cannot be null. (Parameter 'provider')

trueleader commented 3 years ago

Same issue here. We developed a SPA with ASP.NET Core 5 backend and deployed it as Azure Resources. The application additionally needs some background jobs which should be triggered by Azure Functions. Therefore I created a new Project based on the samples here. As soon as I reference our BusinessLogic project (which itself require multiple other projects) the host crashes.

SimiIar to #13 I tried to a downgrade in the AzureFunctions project via: <PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.10" />

This does work, if I additionally remove <PackageReference Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="1.2.0" />

But as soon as I add <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" />

for TimerTrigger support (maybe generally not work yet as of #11 ) it reappears again:

Azure Functions Core Tools Core Tools Version: 3.0.3160 Commit hash: 00aa7f43cc5c5f15241b5e6e5363256f19ceb990 Function Runtime Version: 3.0.14916.0 [2020-12-22T14:03:28.623Z] Building host: startup suppressed: 'False', configuration suppressed: 'False', startup operation id: 'e748f8b9-fe3e-48b6-a3b4-4c506b0286f2' [2020-12-22T14:03:28.644Z] Reading host configuration file 'C:\Projects\git\Gate-TTTool\src\TTTool.AzureFunctions\bin\output\host.json' [2020-12-22T14:03:28.648Z] Host configuration file read: [2020-12-22T14:03:28.651Z] { [2020-12-22T14:03:28.654Z] "version": "2.0" [2020-12-22T14:03:28.681Z] } [2020-12-22T14:03:28.693Z] Loading functions metadata [2020-12-22T14:03:28.726Z] FUNCTIONS_WORKER_RUNTIME set to dotnet-isolated. Skipping WorkerConfig for language:java [2020-12-22T14:03:28.729Z] FUNCTIONS_WORKER_RUNTIME set to dotnet-isolated. Skipping WorkerConfig for language:node [2020-12-22T14:03:28.734Z] FUNCTIONS_WORKER_RUNTIME set to dotnet-isolated. Skipping WorkerConfig for language:powershell [2020-12-22T14:03:28.738Z] FUNCTIONS_WORKER_RUNTIME set to dotnet-isolated. Skipping WorkerConfig for language:python [2020-12-22T14:03:28.757Z] 0 functions loaded [2020-12-22T14:03:28.877Z] A host error has occurred during startup operation 'e748f8b9-fe3e-48b6-a3b4-4c506b0286f2'. [2020-12-22T14:03:28.880Z] TTTool.AzureFunctions: Method not found: 'Microsoft.Extensions.Configuration.IConfigurationBuilder Microsoft.Azure.WebJobs.Hosting.IWebJobsConfigurationBuilder.get_ConfigurationBuilder()'. Value cannot be null. (Parameter 'provider') [2020-12-22T14:03:28.896Z] Initialization cancellation requested by runtime. [2020-12-22T14:03:28.903Z] Stopping host... [2020-12-22T14:03:28.905Z] Host shutdown completed.

rpelavin commented 3 years ago

Hitting the same issue. Easily reproduced by cloning the repository and adding a package reference to Microsoft.Extensions.Configuration.Json v5.0.0, per @machekku's comments above.

rpelavin commented 3 years ago

Looks like this may just be a matter of updating the worker package references from 1.0.0-preview1 to 1.0.0-preview3. Once I updated to the following, I was able to get the project running:

 <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.0.0-preview3" OutputItemType="Analyzer" />
 <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.0.0-preview3" />
ankitkumarr commented 3 years ago

As called out above, this should be fixed with 1.0.0-preview3. We have updated the samples with this version.