Azure EventHubs Extensions
Besides the Azure EventHubs message handling functionality, we provide several additional features related to message creation/sending and message/context discoverability. They help in hte send/receive process of Azure EventHubs event messages.
Installation
These features require to install our NuGet package:
PM > Install-Package Arcus.Messaging.EventHubs.Core
Using Arcus secret store when registering the EventHubs producer client
When registering an EventHubsProducerClient
via Azure's client registration process, the library provides an extension to pass-in a secret name instead of directly passing the Azure EventHubs connection string.
This secret name will correspond with a registered secret in the Arcus secret store that holds the Azure EventHubs connection string.
⚠ An Azure EventHubs connection string can either contain the
EntityPath
or not if it was copied from the EventHubs namespace or from the EventHub itself. In either case, make sure that you either pass in the EventHub name separately, or that the connection string contains this name. For more information, see: How to get an Event Hubs connection string.
Following example shows how the secret name is passed to this extension overload:
using Microsoft.Extensions.Azure;
using Microsoft.Extensions.DependencyInjection;
public class Program
{
public void ConfigureServices(IServiceCollection services)
{
// Adding Arcus secret store, more info: https://security.arcus-azure.net/features/secret-store
services.AddSecretStore(stores => stores.AddAzureKeyVaultWithManagedIdentity("https://my.vault.azure.net");
// Adding EventHubs producer client with secret in Arcus secret store,
// using connection string that contains EventHubs name.
services.AddAzureClients(clients => clients.AddEventHubProducerClient(connectionStringSecretName: "<your-secret-name>"));
// Adding EventHubs producer client with secret in Arcus secret store,
// using connection string that does not contain EventHubs name.
services.AddAzureClients(clients => clients.AddEventHubProducerClient(connectionStringSecretName: "<your-secret-name>", "<eventhubs-name>"));
}
}