Azure-Functions
Azure-Functions copied to clipboard
IHttpClientFactory issues with function startup
I would like to use the new IHttpClientFactory interface to create HttpClients as described in this MS doc:
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-2.2
However, when I add the nuget package Microsoft.Extensions.Http to my project, the functions fail to load correctly and results in a runtime error (Http 500 - Internal Server Error)
Steps to repro:
- Create a new Azure function project in Visual Studio 2017 or VScode (with Azure functions extension)
- Add the nuget package Microsoft.Extensions.Http 2.2.0 to your project
- Press F5 to execute the function locally.
- Error appears when func is starting
Terminal output
> Executing task: func host start <
%%%%%%
%%%%%%
@ %%%%%% @
@@ %%%%%% @@
@@@ %%%%%%%%%%% @@@
@@ %%%%%%%%%% @@
@@ %%%% @@
@@ %%% @@
@@ %% @@
%%
%
Azure Functions Core Tools (2.3.199 Commit hash: fdf734b09806be822e7d946fe17928b419d8a289)
Function Runtime Version: 2.0.12246.0
Skipping 'AzureWebJobsStorage' from local settings as it's already defined in current environment variables.
[12/27/18 6:07:38 AM] Starting Rpc Initialization Service.
[12/27/18 6:07:38 AM] Initializaing RpcServer
[12/27/18 6:07:38 AM] Building host: startup suppressed:False, configuration suppressed: False
[12/27/18 6:07:38 AM] Reading host configuration file '/Users/jordanchang/Desktop/func1/bin/Debug/netcoreapp2.1/host.json'
[12/27/18 6:07:38 AM] Host configuration file read:
[12/27/18 6:07:38 AM] {
[12/27/18 6:07:38 AM] "version": "2.0"
[12/27/18 6:07:38 AM] }
[12/27/18 6:07:39 AM] Initializing Host.
[12/27/18 6:07:39 AM] Host initialization: ConsecutiveErrors=0, StartupCount=1
[12/27/18 6:07:39 AM] Starting JobHost
[12/27/18 6:07:39 AM] Starting Host (HostId=chachabook-1876658138, InstanceId=42eb9fd5-038d-489a-9af6-7191c9823ccf, Version=2.0.12246.0, ProcessId=84543, AppDomainId=1, InDebugMode=False, InDiagnosticMode=False, FunctionsExtensionVersion=)
[12/27/18 6:07:39 AM] Loading functions metadata
[12/27/18 6:07:40 AM] 1 functions loaded
[12/27/18 6:07:40 AM] WorkerRuntime: dotnet. Will shutdown other standby channels
[12/27/18 6:07:41 AM] Generating 1 job function(s)
[12/27/18 6:07:44 AM] Error indexing method 'HttpTriggerCSharp.Run'
[12/27/18 6:07:44 AM] Microsoft.Azure.WebJobs.Host: Error indexing method 'HttpTriggerCSharp.Run'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'log' to type ILogger. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
[12/27/18 6:07:44 AM] Function 'HttpTriggerCSharp.Run' failed indexing and will be disabled.
[12/27/18 6:07:44 AM] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
[12/27/18 6:07:44 AM] Host initialized (5067ms)
[12/27/18 6:07:44 AM] Host started (5090ms)
[12/27/18 6:07:44 AM] Job host started
Hosting environment: Production
Content root path: /Users/jordanchang/Desktop/func1/bin/Debug/netcoreapp2.1
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
Http Functions:
HttpTriggerCSharp: [GET,POST] http://localhost:7071/api/HttpTriggerCSharp
I think this is related https://github.com/Azure/azure-functions-host/issues/3611
Closing in favor of issue on host repo