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

EventHubs health check doesn't specify EntityPath / EventHubName causing failure #7814

Open
eerhardt opened this issue Feb 27, 2025 · 1 comment
Assignees
Labels
area-integrations Issues pertaining to Aspire Integrations packages azure Issues associated specifically with scenarios tied to using Azure azure-eventhubs Issues related to Azure Event Hubs integration
Milestone

Comments

@eerhardt
Copy link
Member

When you reference an EventHubs namespace, use the emulator, and use an EventHub consumer client, the new EventHubs health checks doesn't create the connection string correctly.

We have this code for the "real clients":

// If no connection is provided use TokenCredential
if (string.IsNullOrEmpty(settings.ConnectionString))
{
return new EventHubProducerClient(settings.FullyQualifiedNamespace, settings.EventHubName, cred, options);
}
// If no specific EventHubName is provided, it has to be in the connection string
if (string.IsNullOrEmpty(settings.EventHubName))
{
return new EventHubProducerClient(settings.ConnectionString, options);
}
return new EventHubProducerClient(settings.ConnectionString, settings.EventHubName, options);

But when we create the EventHubProducerClient for the health check, we aren't doing the check for the EventHubName:

_healthCheckClient = !string.IsNullOrEmpty(settings.ConnectionString) ?
new EventHubProducerClient(settings.ConnectionString, producerClientOptions) :
new EventHubProducerClient(settings.FullyQualifiedNamespace, settings.EventHubName, settings.Credential ?? new DefaultAzureCredential(), producerClientOptions);

Repro Steps

AppHost:

var eventhubns = builder.AddAzureEventHubs("eventhubns")
    .RunAsEmulator();

eventhubns.AddHub("eventhub");

builder.AddProject<Projects.EventHubsConsumer>("consumer")
    .WithReference(eventhubns).WaitFor(eventhubns);

Consumer App:

var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults();

builder.AddAzureEventHubBufferedProducerClient("eventhubns", settings => settings.EventHubName = "eventhub");

...

F5 and hit the Consumer App's /health endpoint.

Expected results

Should be Healthy

Actual results

An unhandled exception occurred while processing the request.
ArgumentException: The connection string used for an Event Hub client must specify the Event Hubs namespace host, and either a Shared Access Key (both the name and value) or Shared Access Signature to be valid. The path to an Event Hub must be included in the connection string or specified separately. (Parameter 'connectionString')
@eerhardt
Copy link
Member Author

cc @sebastienros @oising

@eerhardt eerhardt added area-integrations Issues pertaining to Aspire Integrations packages azure Issues associated specifically with scenarios tied to using Azure azure-eventhubs Issues related to Azure Event Hubs integration labels Feb 27, 2025
@eerhardt eerhardt added this to the 9.2 milestone Feb 27, 2025
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 azure Issues associated specifically with scenarios tied to using Azure azure-eventhubs Issues related to Azure Event Hubs integration
Projects
None yet
Development

No branches or pull requests

2 participants