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

Add Azure Event Hubs component #1147

Closed
ReubenBond opened this issue Nov 30, 2023 · 15 comments
Closed

Add Azure Event Hubs component #1147

ReubenBond opened this issue Nov 30, 2023 · 15 comments
Assignees
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication area-integrations Issues pertaining to Aspire Integrations packages azure Issues associated specifically with scenarios tied to using Azure

Comments

@ReubenBond
Copy link
Member

We should add an Azure Event Hubs component.
We identified this in the Orleans component PR (#1117), since many Orleans users use Azure Event Hubs for stream processing.

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-integrations Issues pertaining to Aspire Integrations packages label Nov 30, 2023
@DamianEdwards DamianEdwards added the azure Issues associated specifically with scenarios tied to using Azure label Nov 30, 2023
@davidfowl davidfowl added this to the preview TBD (but in 8.0) milestone Dec 1, 2023
@davidfowl davidfowl added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Feb 25, 2024
@davidfowl
Copy link
Member

davidfowl commented Feb 25, 2024

I wrote an event hubs sample here (no component but an azure resource):

@oising
Copy link
Contributor

oising commented Mar 10, 2024

@davidfowl helped me get started this weekend on getting his example integrated into the latest bits, so if you want to assign me, I'm giving it a shot. /cc @ReubenBond

@ReubenBond
Copy link
Member Author

Greatly appreciated, @oising! We're here to help if you run into trouble

@jsquire
Copy link
Member

jsquire commented Mar 11, 2024

@davidfowl helped me get started this weekend on getting his example integrated into the latest bits, so if you want to assign me, I'm giving it a shot. /cc @ReubenBond

@oising : One thing that I'll mention about David's prototype is that you definitely don't want to use the consumer's ReadEventsAsync for production scenarios unless you've got a very low volume. As noted in the docs, that method is intended to provide an easy "Hello World" experience for exploring Event Hubs. It doesn't provide any fairness guarantees when reading from partitions, does not scale well with a large number of partitions, nor perform under load.

Depending on whether the intention is to allow for multiple instances to be running in the app or a single instance, we'd want to look at PluggableCheckpointStoreEventProcessor<T> or PartitionReceiver.

@oising
Copy link
Contributor

oising commented Mar 11, 2024

@jsquire This brings up another somewhat orthogonal point. I've yet to read anything about Aspire being aimed at production scenarios (though I can absolutely imagine this, especially with something like Pulumi integrated) -- Aspire finds itself in a weird no-mans land here. It would be good to get messaging around this, because these choices (PartitionReceiver vs EventHubConsumer) are entwined with this vision.

@davidfowl
Copy link
Member

The libraries (components) are runtime libraries. We don't have to choose here, we just have a lightweight wrapper around the event hub azure SDK.

@davidfowl
Copy link
Member

davidfowl commented Mar 11, 2024

@sebastienros will help guide this @oising. Feel free to ask questions here!

@jsquire
Copy link
Member

jsquire commented Mar 12, 2024

The libraries (components) are runtime libraries. We don't have to choose here, we just have a lightweight wrapper around the event hub azure SDK.

Cool. That makes things easier. If the goal is just to wrap/expose clients, then we should consider doing so for:

  • EventHubProducerClient
  • EventHubProcessorClient
  • PartitionReceiver
  • EventHubBufferedProducerClient

@jsquire
Copy link
Member

jsquire commented Mar 12, 2024

@jsquire This brings up another somewhat orthogonal point. I've yet to read anything about Aspire being aimed at production scenarios (though I can absolutely imagine this, especially with something like Pulumi integrated) -- Aspire finds itself in a weird no-mans land here. It would be good to get messaging around this, because these choices (PartitionReceiver vs EventHubConsumer) are entwined with this vision.

That is outside of my purview; I'll defer to @sebastienros and team.

@oising
Copy link
Contributor

oising commented Mar 12, 2024

The libraries (components) are runtime libraries. We don't have to choose here, we just have a lightweight wrapper around the event hub azure SDK.

Cool. That makes things easier. If the goal is just to wrap/expose clients, then we should consider doing so for:

  • EventHubProducerClient
  • EventHubProcessorClient
  • PartitionReceiver
  • EventHubBufferedProducerClient

I don't think there's precedent for exposing multiple clients in this way; even ASB just uses ServiceBusClient I think. I'll play around with some ideas and put up a draft soon.

@jsquire
Copy link
Member

jsquire commented Mar 12, 2024

I don't think there's precedent for exposing multiple clients in this way; even ASB just uses ServiceBusClient I think. I'll play around with some ideas and put up a draft soon.

Fair enough; if we only get one producer and one consumer, we'd probably want to go with:

  • EventHubProducerClient
  • EventProcessorClient

@oising
Copy link
Contributor

oising commented Mar 12, 2024

I don't think there's precedent for exposing multiple clients in this way; even ASB just uses ServiceBusClient I think. I'll play around with some ideas and put up a draft soon.

Fair enough; if we only get one producer and one consumer, we'd probably want to go with:

  • EventHubProducerClient
  • EventProcessorClient

That's still new territory as far as I can tell. The Aspire component for ASB only has a single top-level/root client ServiceBusClient that needs to be configured. After that, it's vanilla SDK to get a sender or receiver for a queue or a topic. With the Event Hub, there are multiple top-level clients, and some of which have further dependencies, such as a storage account for checkpointing. As far as I understand that how that might work [configuring the storage account], that is vanilla SDK also, even though we may garner the connection reference from an Aspire storage account component. I'm just drinking coffee and figuring it all out. No stress :)

@oising
Copy link
Contributor

oising commented Mar 12, 2024

I'm thinking of following the pattern in Microsoft.Extensions.Azure:

distributedBuilder.AddEventHubClients(clientBuilder => {
       clientBuilder.AddEventHubProducerClient(...)
       clientBuilder.AddKeyedEventHubProducerClient(...)
       clientBuilder.AddEventProcessorClient(...)
       clientBuilder.AddKeyedEventProcessorClient(...)
       // etc..
       
       clientBuilder.UseCredential( ... )
});

Thoughts?

p.s. I kinda like this pattern for all of Aspire components (at least until they are integrated into the SDK if that happens)

i.e.

builder.AddAspireClients(aspire => { 
    aspire.AddServiceBus( ... )
    aspire.AddStorageAccount( ... )
    // etc 
}); 

It fits within the AddAzureClients pattern, and also helps you a bit more to not conflate the components with the vanilla SDK extension methods.

@davidfowl
Copy link
Member

@oising no plans to fundamentally change the pattern from a top-level method, especially for the simple case. We can always add more advanced overloads. We just need to nail the 95% scenario. Customers can always use the lower-level APIs.

@davidfowl
Copy link
Member

Done!

@github-actions github-actions bot locked and limited conversation to collaborators Apr 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication area-integrations Issues pertaining to Aspire Integrations packages azure Issues associated specifically with scenarios tied to using Azure
Projects
None yet
Development

No branches or pull requests

7 participants