Azure-functions-core-tools: Method not found: 'Microsoft.Extensions.Primitives.StringValues Microsoft.AspNetCore.Http.IQueryCollection.get_Item(System.String)'

Created on 2 Oct 2018  路  18Comments  路  Source: Azure/azure-functions-core-tools

Keep getting this error when I create a new function on:
Azure Functions Core Tools (2.0.3)
Function Runtime Version: 2.0.12115.0
VS 2017 15.8.5.
This is the plain vanilla Function1 type of project.
Thanks
Herald



[10/2/2018 8:12:11 PM] Executing 'Function1' (Reason='This function was programmatically called via the host APIs.', Id=dd86ca07-b93b-4bbb-b868-d9e0b200b45e)
[10/2/2018 8:12:12 PM] Executed 'Function1' (Failed, Id=dd86ca07-b93b-4bbb-b868-d9e0b200b45e)
[10/2/2018 8:12:12 PM] System.Private.CoreLib: Exception while executing function: Function1. afunc_datafeeds_airports: **Method not found: 'Microsoft.Extensions.Primitives.StringValues Microsoft.AspNetCore.Http.IQueryCollection.get_Item(System.String)'.**
fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HLH8KDB621VD", Request id "0HLH8KDB621VD:00000001": An unhandled exception was thrown by the application.
Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: Function1 ---> System.MissingMethodException: Method not found: 'Microsoft.Extensions.Primitives.StringValues Microsoft.AspNetCore.Http.IQueryCollection.get_Item(System.String)'.
   at afunc_datafeeds_airports.Function1.Run(HttpRequest req, ILogger log)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at afunc_datafeeds_airports.Function1.Run(HttpRequest req, ILogger log)
   at lambda_method(Closure , Function1 , Object[] )
   at Microsoft.Azure.WebJobs.Host.Executors.TaskMethodInvoker`2.InvokeAsync(TReflected instance, Object[] arguments) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\TaskMethodInvoker.cs:line 21
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.InvokeAsync(Object instance, Object[] arguments) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInvoker.cs:line 63
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker, ParameterHelper parameterHelper, CancellationTokenSource timeoutTokenSource, CancellationTokenSource functionCancellationTokenSource, Boolean throwOnTimeout, TimeSpan timerInterval, IFunctionInstance instance) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 561
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance, ParameterHelper parameterHelper, ILogger logger, CancellationTokenSource functionCancellationTokenSource) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 508
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(IFunctionInstance instance, ParameterHelper parameterHelper, IFunctionOutputDefinition outputDefinition, ILogger logger, CancellationTokenSource functionCancellationTokenSource) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 444
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(IFunctionInstance instance, FunctionStartedMessage message, FunctionInstanceLogEntry instanceLogEntry, ParameterHelper parameterHelper, ILogger logger, CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 249
   --- End of inner exception stack trace ---
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(IFunctionInstance instance, FunctionStartedMessage message, FunctionInstanceLogEntry instanceLogEntry, ParameterHelper parameterHelper, ILogger logger, CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 293
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance, CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 89
   at Microsoft.Azure.WebJobs.Host.Executors.ExceptionDispatchInfoDelayedException.Throw() in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\ExceptionDispatchInfoDelayedException.cs:line 28
   at Microsoft.Azure.WebJobs.JobHost.CallAsync(String name, IDictionary`2 arguments, CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\JobHost.cs:line 231
   at Microsoft.Azure.WebJobs.Script.WebHost.Features.FunctionExecutionFeature.ExecuteAsync(HttpRequest request, CancellationToken cancellationToken) in C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\Features\FunctionExecutionFeature.cs:line 67
   at Microsoft.Azure.WebJobs.Script.WebHost.Middleware.FunctionInvocationMiddleware.GetResultAsync(HttpContext context, IFunctionExecutionFeature functionExecution) in C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\Middleware\FunctionInvocationMiddleware.cs:line 147
   at Microsoft.Azure.WebJobs.Script.WebHost.Middleware.FunctionInvocationMiddleware.Invoke(HttpContext context) in C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\Middleware\FunctionInvocationMiddleware.cs:line 56
   at Microsoft.Azure.WebJobs.Script.WebHost.Middleware.HttpThrottleMiddleware.Invoke(HttpContext httpContext, IOptions`1 httpOptions, HttpRequestQueue requestQueue, HostPerformanceManager performanceManager, IMetricsLogger metricsLogger) in C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\Middleware\HttpThrottleMiddleware.cs:line 66
   at Microsoft.Azure.WebJobs.Script.WebHost.Middleware.HomepageMiddleware.Invoke(HttpContext context) in C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\Middleware\HomepageMiddleware.cs:line 34
   at Microsoft.AspNetCore.Buffering.ResponseBufferingMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.Azure.WebJobs.Script.WebHost.Middleware.HttpExceptionMiddleware.Invoke(HttpContext context) in C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\Middleware\HttpExceptionMiddleware.cs:line 23
   at Microsoft.Azure.WebJobs.Script.WebHost.Middleware.AppServiceHeaderFixupMiddleware.Invoke(HttpContext httpContext) in C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\Middleware\AppServiceHeaderFixupMiddleware.cs:line 35
   at Microsoft.Azure.WebJobs.Script.WebHost.Middleware.ScriptHostRequestServiceProviderMiddleware.Invoke(HttpContext httpContext, WebJobsScriptHostService manager) in C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\Middleware\ScriptHostRequestServiceProviderMiddleware.cs:line 36
   at Microsoft.Azure.WebJobs.Script.WebHost.Middleware.HostWarmupMiddleware.Invoke(HttpContext httpContext) in C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\Middleware\HostWarmupMiddleware.cs:line 34
   at Microsoft.Azure.WebJobs.Script.WebHost.Middleware.HostAvailabilityCheckMiddleware.Invoke(HttpContext httpContext, IScriptHostManager scriptHostManager) in C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\Middleware\HostAvailabilityCheckMiddleware.cs:line 47
   at Microsoft.Azure.WebJobs.Script.WebHost.Middleware.EnvironmentReadyCheckMiddleware.Invoke(HttpContext httpContext, IScriptWebHostEnvironment webHostEnvironment) in C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\Middleware\EnvironmentReadyCheckMiddleware.cs:line 29
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
      Request finished in 1598.447ms 500
help wanted investigate

All 18 comments

Same here. Any Ideas?

I had this same issue - for me this was fixed by downgrading Microsoft.Extensions.Configuration nuget package from 2.2.0 (preview2) to 2.1.1 (latest stable). Possibly a bug in 2.2.0. Might not be the same cause for you, perhaps with a different package.

@chrismimosil Thanks. That did it. It is always a mismatch between what the Azure Functions CLI in Visual Studio supports and what works in the Azure Portal. I don't know why this is so difficult to keep in sync. It creates a lot of frustration. Thanks.

/cc @fabiocav @soninaren

I'm not sure where Microsoft.Extensions.Configuration comes from. Was that something you explicitly added as a reference to your project?

@ahmelsayed I think Microsoft.Extensions.Configuration was there in my project, before upgrading the Azure Function tool in VS. Obviously it is used to retrieve config values from local files. The strange part was that the same Azure Function would work fine if deployed in Azure, but would fail if run/debugged locally, so it had to do with the Azure Functions Core Tools (2.0.3).

It is very possible that the Microsoft.Extensions.Configuration it is added to the Function when created in Visual Studio via the latest project template. But I cannot fully attest to that since I now run the latest version of Visual Studio (VS 2017 15.8.5) and the current template does not add any libraries.

Thanks

@hgjura can you share the contents of your csproj file?

This is the plain vanilla Function1 type of project.

Do you mean this is Functions v1 app. The reason i ask is because for v1 VS should be using Azure Functions Core Tools (1.0.15) not 2.0.3

@soninaren
It all started when I upgraded VS to its latest version (15.8.5) which in turn I think upgraded Azure Functions Core Tools to 2.0.3...
afunc_datafeeds_processor.zip

[10/18/2018 3:37:44 PM] System.Private.CoreLib: Exception while executing function: : Method not found: 'Microsoft.Extensions.Primitives.StringValues Microsoft.AspNetCore.Http.IQueryCollection.get_Item(System.String)'.

I'm seeing this as well. I don't have ability to downgrade to Configuration 2.1.1 as I'm using EF Core Preview 3.

Any other workarounds?

Azure Functions does not currently support .NET Core 2.2 and the 2.2 preview bits.

Please follow this issue for information and updates on the 2.2 support plans and work.

@hgjura thank you for sharing that file. The project you've shared has a dependency on an external project that is not included and doesn't give us a clear picture of the dependency graph.

Would you be able to share:

  • Detailed repro information, including code that triggers the issue
  • The full exception stack

@fabiocav I am attaching a new .csproj with no dependencies. This is easily reproducible. Eventually this came done to Microsoft.Extensions.Configuration and the fact that it is indeed the preview version (2.2.0-preview3-35497) that throws the error. Once downgraded to v. 2.1.1 it works.
To repro just create a new Function and add the Microsoft.Extensions.Configuration with -pre.
The error happens as soon as you run the function and it starts reading from querystring at this line: string name = req.Query["name"];.
Thanks.
FunctionApp1.zip

@fabiocav I guess you can close this since, it is the preview bit of Microsoft.Extensions.Configuration that throws the error. And this preview is not supported yet.

I'm running into this error with Visual Studio for Mac.

Output from running func:

Azure Functions Core Tools (2.3.199 Commit hash: fdf734b09806be822e7d946fe17928b419d8a289)
Function Runtime Version: 2.0.12246.0

Visual Studio Community 2017 for Mac
Version 7.7.3 (build 43)

Output from running my function app:

Azure Functions Core Tools (2.0.3)
Function Runtime Version: 2.0.12115.0

Output from running my 'GetUser' function:

[2019-01-22 1:40:43 AM] Executed 'GetUser' (Failed, Id=8bf0bca0-d6ab-4423-9a65-33899457973f)
[2019-01-22 1:40:43 AM] System.Private.CoreLib: Exception while executing function: GetUser. UserAPI: Method not found: 'Microsoft.Extensions.Primitives.StringValues Microsoft.AspNetCore.Http.IHeaderDictionary.get_Item(System.String)'.
fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HLK0182I47J1", Request id "0HLK0182I47J1:00000002": An unhandled exception was thrown by the application.
Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: GetUser ---> System.MissingMethodException: Method not found: 'Microsoft.Extensions.Primitives.StringValues Microsoft.AspNetCore.Http.IHeaderDictionary.get_Item(System.String)'.

How can I resolve this? I don't have Microsoft.Extensions.Configuration in my project

So it turns out my own dependency of my project relies on Microsoft.Extensions.Configuration as a dependency, and it just got updated to 2.2.0 (not preview) by the other maintainer. I rolled it back to 2.1.1 and it seems everything is working ok now...

I had a similar issue as described here, I got a Method Not Found Exception, but for set_Mode from the System.ServiceModel.NetTcp package.

I also found that it worked in the tools Visual Studio automatically downloaded, but did not work in the cli tools I downloaded from github.

After 2 days of investigating, it came down to having the "powershell" folder in the worker folder. Once I deleted the powershell folder, everything was fine. I hope this adds some insight or help into the issue, still experiencing the same issue in the cloud however.

Had similar issue when using Microsoft.Extensions.Configuration.* version 3.0.0 dependencies targeting netcoreapp2.1.

Resolved by downgrading dependencies version to 2.20~2.2.4.

Is this not able to target Microsoft.Extensions.Configuration 3.x? How is that possible?

@ltouro @aherrick .NET Core 3.0/ASP.NET Core 3.0 dependencies are supported in the Azure Functions 3.x preview. You can find more details here: https://github.com/Azure/app-service-announcements/issues/200

Closing this as the original issue has been addressed. Please open new issues with details if you have additional questions or continue to run into problems.

Was this page helpful?
0 / 5 - 0 ratings