Skip to content

Configure HttpClientFactory in ClientConfig instance using dependency injection factories #4092

@bdovaz

Description

@bdovaz

Describe the feature

Allow configuring clientConfig.HttpClientFactory through dependency injection factories.

Use Case

I'm faced with the problem that it's not possible to configure clientConfig.HttpClientFactory through AddAWSService<>; there's no overload that allows you to configure that instance using IServiceProvider.

I know that many AWSOptions options can be configured from appsettings.json for example, but that AWSOptions only has a subset of ClientConfig fields and only primitive type fields, not for those that require, for example, an instance of HttpClientFactory:

private ClientConfig CreateConfig(AWSOptions options)

The DefaultClientConfig class does not allow to configure HttpClientFactory:

In my case, I would like to build it with the default factory but be able to configure it later in another step. My intention is to use IAmazonS3 but with: https://learn.microsoft.com/es-es/dotnet/core/extensions/httpclient-factory

Currently, the only way (without using DI, in my case it's not possible as I'm using IHttpClientFactory from Microsoft) is to set AWSConfigs.HttpClientFactory, but this is not ideal as it is static:

public HttpClientFactory HttpClientFactory { get; set; } = AWSConfigs.HttpClientFactory;

Proposed Solution

I suppose it could be solved with a minor change in one of the many PRs created by @chase-miller: #3715 (comment)

I hope they get unblocked somehow because he has done a tremendous job.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

AWS .NET SDK and/or Package version used

AWSSDK.Extensions.NETCore.Setup -> 4.0.3.9
AWSSDK.S3 -> 4.0.9.1

Targeted .NET Platform

.NET 9

Operating System and version

Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    Extensionsfeature-requestA feature should be added or improved.p2This is a standard priority issuequeued

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions