Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for hierarchical configuration in Aspire Components #800

Open
eerhardt opened this issue Nov 14, 2023 · 2 comments
Open

Allow for hierarchical configuration in Aspire Components #800

eerhardt opened this issue Nov 14, 2023 · 2 comments
Labels
area-integrations Issues pertaining to Aspire Integrations packages
Milestone

Comments

@eerhardt
Copy link
Member

eerhardt commented Nov 14, 2023

When using "named" or "keyed DI" components, the settings/configuration should be configured hierarchically, so common settings can be set at Aspire:Abc and each named section can provide settings specific to it. The named settings override the common settings.

For example:

{
  "Aspire": {
    "Abc": {
      "MySetting": true,

      "named_one": {
        // inherits MySetting=true
      },
      "named_two": {
        "MySetting": false
      }
    }
  }
}

Similarly for Azure, the ClientOptions can be configured hierarchically as well, so common Azure options can be configured for all Azure components. And each component can override the shared settings.

{
  "Aspire": {
    "Azure": {
      // These ClientOptions apply to all Azure components
      "ClientOptions": {
        "RetryOptions": {
          "MaxRetries": 2,
          "Delay": "00:00:01"
        }
      },

      "Messaging:ServiceBus": {
        "Namespace": "aspire-servicebus.servicebus.windows.net",

        // These ClientOptions apply to the ServiceBus component and override the above options
        "ClientOptions": {
          "RetryOptions": {
            "MaxRetries": 3
          }
        }
      }
    }
  }
}

Note that the Azure SDK is planning on adding some IConfiguration integration. We should ensure the Aspire configuration story lines up well with the work they are doing.

When this is implemented, please update the https://github.com/dotnet/aspire/blob/main/src/Components/README.md with the information so all component authors add support.

cc @tg-msft @schaabs

@eerhardt eerhardt added the area-integrations Issues pertaining to Aspire Integrations packages label Nov 14, 2023
eerhardt added a commit that referenced this issue Nov 14, 2023
These aren't implemented yet and are tracked by #800. Removing these sections for now so people aren't confused.
@pedershk
Copy link

Is Keyed DI (i.,e. multiple named instances) now supported in .NET Aspire Components? I noticed components are added as Singletons to DI when using the component. Are they stored with the name, making multiple additions of same service type possible in a single AppDomain?

@davidfowl
Copy link
Member

Yes it's supported. Aspire components have AddKeyed* overloads that support providing a name.

@eerhardt eerhardt added this to the Backlog milestone Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-integrations Issues pertaining to Aspire Integrations packages
Projects
None yet
Development

No branches or pull requests

3 participants