Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.

Add Azure Event Hubs component +#587

Merged
IEvangelist merged 4 commits intodotnet:preview-5from
IEvangelist:event-hubs
Apr 4, 2024
Merged

Add Azure Event Hubs component +#587
IEvangelist merged 4 commits intodotnet:preview-5from
IEvangelist:event-hubs

Conversation

@IEvangelist
Copy link
Copy Markdown
Member

@IEvangelist IEvangelist commented Apr 4, 2024

@IEvangelist IEvangelist requested a review from tdykstra April 4, 2024 18:30
@dotnet-bot dotnet-bot added database Content related to database. messaging Content related to messaging. security Content related to security. storage Content related to storage. labels Apr 4, 2024
@IEvangelist IEvangelist merged commit e7665e4 into dotnet:preview-5 Apr 4, 2024
Copy link
Copy Markdown
Contributor

@tdykstra tdykstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I left a few minor suggestions.


The following example assumes that you have an Azure Event Hubs namespace and an Event Hub created and wish to configure an `EventHubProducerClient` to send events to the Event Hub. The `EventHubConsumerClient`, `EventProcessorClient`, and `PartitionReceiver`are configured in a similar manner.

In the _Program.cs_ file of your component-consuming project, call the `AddAzureEventHubProducerClient` extension to register a `EventHubProducerClient` for use via the dependency injection container.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In the _Program.cs_ file of your component-consuming project, call the `AddAzureEventHubProducerClient` extension to register a `EventHubProducerClient` for use via the dependency injection container.
In the _Program.cs_ file of your component-consuming project, call the `AddAzureEventHubProducerClient` extension to register an `EventHubProducerClient` for use via the dependency injection container.

The `AddAzureEventHubs` method will read connection information from the AppHost's configuration (for example, from "user secrets") under the `ConnectionStrings:eventHubsConnectionName` config key. The `WithReference` method passes that connection information into a connection string named `eventHubsConnectionName` in the `ExampleService` project.

> [!IMPORTANT]
> Even though we are creating an Event Hub using the `AddEventHub` at the same time as the namespace, as of .NET Aspire version `preview-5`, the connection string will not include the `EntityPath` property, so the `EventHubName` property must be set in the settings callback for the preferred client. Future versions of Aspire will include the `EntityPath` property in the connection string and will not require the `EventHubName` property to be set in this scenario.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> Even though we are creating an Event Hub using the `AddEventHub` at the same time as the namespace, as of .NET Aspire version `preview-5`, the connection string will not include the `EntityPath` property, so the `EventHubName` property must be set in the settings callback for the preferred client. Future versions of Aspire will include the `EntityPath` property in the connection string and will not require the `EventHubName` property to be set in this scenario.
> Even though we are creating an Event Hub using the `AddEventHub` method at the same time as the namespace, as of .NET Aspire version `preview-5`, the connection string will not include the `EntityPath` property. So the `EventHubName` property must be set in the settings callback for the preferred client. Future versions of Aspire will include the `EntityPath` property in the connection string and will not require the `EventHubName` property to be set in this scenario.

> [!IMPORTANT]
> Even though we are creating an Event Hub using the `AddEventHub` at the same time as the namespace, as of .NET Aspire version `preview-5`, the connection string will not include the `EntityPath` property, so the `EventHubName` property must be set in the settings callback for the preferred client. Future versions of Aspire will include the `EntityPath` property in the connection string and will not require the `EventHubName` property to be set in this scenario.

In the _Program.cs_ file of `ExampleService`, the connection can be consumed using by calling of the supported Event Hubs client extension methods:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In the _Program.cs_ file of `ExampleService`, the connection can be consumed using by calling of the supported Event Hubs client extension methods:
In the _Program.cs_ file of `ExampleService`, the connection can be consumed by calling the supported Event Hubs client extension methods:

});
```

And then the connection information will be retrieved from the `ConnectionStrings` configuration section. Two connection formats are supported:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
And then the connection information will be retrieved from the `ConnectionStrings` configuration section. Two connection formats are supported:
And then the connection information is retrieved from the `ConnectionStrings` configuration section. Two connection formats are supported:


### Use configuration providers

The .NET Aspire Azure Event Hubs library supports [Microsoft.Extensions.Configuration](https://learn.microsoft.com/dotnet/api/microsoft.extensions.configuration). It loads the `AzureMessagingEventHubsSettings` and the associated Options, e.g. `EventProcessorClientOptions`, from configuration by using the `Aspire:Azure:Messaging:EventHubs:` key prefix, followed by the name of the specific client in use. For example, consider the `appsettings.json` that configures some of the options for an `EventProcessorClient`:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The .NET Aspire Azure Event Hubs library supports [Microsoft.Extensions.Configuration](https://learn.microsoft.com/dotnet/api/microsoft.extensions.configuration). It loads the `AzureMessagingEventHubsSettings` and the associated Options, e.g. `EventProcessorClientOptions`, from configuration by using the `Aspire:Azure:Messaging:EventHubs:` key prefix, followed by the name of the specific client in use. For example, consider the `appsettings.json` that configures some of the options for an `EventProcessorClient`:
The .NET Aspire Azure Event Hubs library supports [Microsoft.Extensions.Configuration](https://learn.microsoft.com/dotnet/api/microsoft.extensions.configuration). It loads the `AzureMessagingEventHubsSettings` and the associated Options, such as `EventProcessorClientOptions`, from configuration by using the `Aspire:Azure:Messaging:EventHubs:` key prefix, followed by the name of the specific client in use. For example, consider the `appsettings.json` that configures some of the options for an `EventProcessorClient`:

}
```

You can also setup the Options type using the optional `Action<IAzureClientBuilder<EventProcessorClient, EventProcessorClientOptions>> configureClientBuilder` parameter of the `AddAzureEventProcessorClient` method. For example, to set the processor's client ID for this client:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can also setup the Options type using the optional `Action<IAzureClientBuilder<EventProcessorClient, EventProcessorClientOptions>> configureClientBuilder` parameter of the `AddAzureEventProcessorClient` method. For example, to set the processor's client ID for this client:
You can also set up the Options type by using the optional `Action<IAzureClientBuilder<EventProcessorClient, EventProcessorClientOptions>> configureClientBuilder` parameter of the `AddAzureEventProcessorClient` method. For example, to set the processor's client ID for this client:

IEvangelist added a commit that referenced this pull request Apr 9, 2024
* Add diagnostics overview page (#543)

* Fix #521

* Try fixing xref

* Add placeholder for preview-5 what's new (#558)

* Add details about hosting components. (#559)

* Add details about hosting components. Fixes #538

* Clean up description

* Feedback

* Fix warnings

* Fix text, packages over components for hosting

* Add new article to fix #551 (#562)

* Add new article to fix #551

* fix tabs and correct text

* Change from plaintext to output

* Change alert

* Update preview-5.md

* Update preview-5.md

* Add healthz details (#563)

* Add healthz details

* Touch date

* Upgrade node-version

* Sync with main

* Fix MD lint issues

* Added a section about custom service defaults (#560)

* Update SD content, fixes #549

* Highlight dependency and add link/alert

* Remove AddBuiltInMeters() (#518)

Update the documentation to use built-in OpenTelemetry instrumentation.

* Try sync with source (#570)

* Update preview-5.md

* Added a few bits about templates (#572)

* Added a few bits about templates

* Fix more MD lint issues

* Initial bits for hosting changes. (#561)

* Initial bits for hosting changes. Fixes #535

* Clean up list and text

* Updated, let's go

* Deployment scenarios with k8s (#583)

* Try sync with source (#570)

* Initial bits for hosting changes. (#561)

* Initial bits for hosting changes. Fixes #535

* Clean up list and text

* Updated, let's go

* Add k8s content

* Apply suggestions from code review

Co-authored-by: Tom Dykstra <tdykstra@microsoft.com>

* Apply suggestions from code review

---------

Co-authored-by: Tom Dykstra <tdykstra@microsoft.com>

* Add seq component (#584)

* Add seq component

* fixes

* link fix

* Apply suggestions from code review

Co-authored-by: David Pine <david.pine@microsoft.com>

---------

Co-authored-by: David Pine <david.pine@microsoft.com>

* Nats component (#586)

* Add NATS component

* lint fixes

* fixes

* fix links

* fix toc

* Add Azure Event Hubs component + (#587)

* Many fixes

* touch dates.

* Add to TOC

* Remove from TOC

* Update component section of preview5.

* Correct package as Azure AI hosting

* Add missing PostgreSQL hosting package

* Clean up custom impl of service defaults

* Initial content for preview 5. (#588)

* Initial effort for local provisioning (#589)

* Initial effort for local provisioning

* TOC

* Images and lightbow

* Fix rendering issue

* Tweak lightbox

* Reposition article in TOC

* Update docs/deployment/azure/local-provisioning.md

Co-authored-by: David Fowler <davidfowl@gmail.com>

* Remove zones

* A bit of clean up for preview-5

* Move NATs

* A few fixes

* Fix image

---------

Co-authored-by: David Fowler <davidfowl@gmail.com>

* added tooling features

* A few bits of cleanup

* Added note about upgrade assistant tooling

* More P5 updates across Azure, AppModel and manifest. (#596)

* More P5 updates across Azure, AppModel and manifest.

* Apply suggestions from code review

* Apply suggestions from code review

---------

Co-authored-by: David Pine <david.pine.7@gmail.com>

* Another major edit pass, with several more to go

* Add link

* A few more bits of cleanup

* Add link to templates

* Fix xUnit template description

* Another edit pass

* Add link to upgrade with assitant

* Remove .NET Core naming

* For more info

* Update docs/fundamentals/setup-tooling.md

Co-authored-by: Aditya Mandaleeka <adityamandaleeka@users.noreply.github.com>

* Fixed headings affecting TOC

* Remove IDE protocol ending

* Making dashboard auth be explicit on the config auth name

* Dashboard section update

* Dash

* Update

* Update

* Update

* Apply suggestions from code review

* Update preview-5.md

* Fix docker command

* Add with external endpoint API

* Fix non-nuget link warnings, and other CI issues

* Fix last absolute link warning

* Add ASPIRE_ALLOW_UNSECURED_TRANSPORT details

* Minor tweaks

* Typo

* Apply suggestions from code review

Co-authored-by: David Fowler <davidfowl@gmail.com>

* Touch

* Add AWS bits

* Correct link

---------

Co-authored-by: David Fowler <davidfowl@gmail.com>
Co-authored-by: Martin Costello <martin@martincostello.com>
Co-authored-by: kvenkatrajan <102772054+kvenkatrajan@users.noreply.github.com>
Co-authored-by: Tom Dykstra <tdykstra@microsoft.com>
Co-authored-by: alexwolfmsft <93200798+alexwolfmsft@users.noreply.github.com>
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
Co-authored-by: Mitch Denny <midenn@microsoft.com>
Co-authored-by: bradygaster <bradyg@microsoft.com>
Co-authored-by: Tim Heuer <tim@timheuer.com>
Co-authored-by: Aditya Mandaleeka <adityamandaleeka@users.noreply.github.com>
Co-authored-by: James Newton-King <james@newtonking.com>
@IEvangelist IEvangelist deleted the event-hubs branch May 1, 2024 19:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

database Content related to database. messaging Content related to messaging. security Content related to security. storage Content related to storage.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants