Skip to content

Commit 612bb59

Browse files
authored
Change DI sample to use IHttpClientFactory
HttpClient cannot be directly injected into a function class like this. See here for the explanation: Azure/azure-functions-host#4520 (comment)
1 parent 034da7c commit 612bb59

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

articles/azure-functions/functions-dotnet-dependency-injection.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ namespace MyNamespace
6464
private readonly IMyService _service;
6565
private readonly HttpClient _client;
6666

67-
public HttpTrigger(IMyService service, HttpClient client)
67+
public HttpTrigger(IMyService service, IHttpClientFactory httpClientFactory)
6868
{
6969
_service = service;
70-
_client = client;
70+
_client = httpClientFactory.CreateClient();;
7171
}
7272

7373
[FunctionName("GetPosts")]

0 commit comments

Comments
 (0)