Playground - how does AspireEventHub connect to storage for checkpoints? #3673
-
The playground for Azure Event Hub https://github.com/dotnet/aspire/tree/main/playground/AspireEventHub uses Azure Storage for checkpoints: AppHost/Program.cs: var blob = builder.AddAzureStorage("ehstorage")
.AddBlobs("checkpoints");
var eventHub = builder.AddAzureEventHubs("eventhubns")
.AddEventHub("hub");
builder.AddProject<Projects.EventHubsConsumer>("consumer")
.WithReference(eventHub)
.WithReference(blob); With a previous version, the storage account was connected with the settings of event processor client configuration: EventHubsConsumer/Program.cs: builder.AddAzureEventProcessorClient("eventhubns",
settings =>
{
settings.EventHubName = "hub";
settings.BlobClientConnectionName = "checkpoints";
});
builder.Services.AddHostedService<Processor>();
Console.WriteLine("Starting EventProcessorClient..."); This is no longer the case with the new version: EventHubsConsumer/Program.cs: builder.AddAzureBlobClient("checkpoints");
builder.AddAzureEventProcessorClient("eventhubns",
settings =>
{
settings.EventHubName = "hub";
}); I couldn't find where the connection between the hub and storage is now. From this pull request #3293 I've seen
The Thanks for implementing this component @oising :-) I just need it for the current chapter I'm working on. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi Christian -- simply put, the EventProcessorClient component will now look for a BlobServiceClient in the default (non-keyed) DI container, and then create a BlobContainerClient from it for the checkpointing. If it doesn't find one, it will now throw an InvalidOperationException with a hint about the problem. I agree it's less explicit and more magical in p5, but if you want more explicit behaviour, add a keyed blob client component using AddKeyedAzureBlobClient and then you'll have to provide the BlobClientServiceKey name on the EH client settings to match the keyed service name. |
Beta Was this translation helpful? Give feedback.
Hi Christian -- simply put, the EventProcessorClient component will now look for a BlobServiceClient in the default (non-keyed) DI container, and then create a BlobContainerClient from it for the checkpointing. If it doesn't find one, it will now throw an InvalidOperationException with a hint about the problem. I agree it's less explicit and more magical in p5, but if you want more explicit behaviour, add a keyed blob client component using AddKeyedAzureBlobClient and then you'll have to provide the BlobClientServiceKey name on the EH client settings to match the keyed service name.