A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/Azure/Azure-Functions/issues/1911 below:

Remove HttpClient as a registered service · Issue #1911 · Azure/Azure-Functions · GitHub

Proposal to fix Azure/azure-functions-host#7236 by removing the registration of HttpClient from DI in the Functions Host.

Discussion link: #1913

Motivation

.NET has an IHttpClientFactory, which is the correct pattern for using HttpClient with DI. The HttpClient class was registered with DI early in Functions v2 and we didn't realize the mistake until we enabled Dependency Injection for .NET in-proc applications.

Impact

It's unclear as this would exist in customer constructor injection. I'm not sure whether it matters in this case, as we need to avoid this pattern, and the fix is pretty straightforward for customers.

Compat-mode support

We could support a compat-mode flag here, if necessary. But because this is an incorrect pattern, I'd like to force customers to update their code.

Alternatives

None discussed.

Detection

If we remove all usage of HttpClient internally, we could maintain a DI factory so that, if called, it logs an exception that causes a host failure. Without an HttpClient registered, customers will get a null ref in their constructors that have an HttpClient parameter.

Support

With a proper error message linking to breaking change documentation, we should be able to deflect support cases.

Documentation

There is one place in our documentation that needs updating. However, this can be updated now with the proper pattern.

Components impacted

Just the functions host.

Performance

No perf impact.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4