Home > other >  How to get the data from azure event hub?
How to get the data from azure event hub?

Time:11-05

I'm exploring using azure event hub as an event consumer.

So my .NET application sends events to the azure event hub. The event hub by default has 4 partitions.

I want the events to be stored in the azure blob storage and also be passed to another .NET application.

This question is to ask - whether the azure event hub has the ability to push the events to the blob and to my .NET application, or will the subscriber (blob and .NET application) need to pull the data from the azure event hub partition?

Or will my .NET subscriber need to pull events from the azure blob?

CodePudding user response:

You need to create a receiver using .Net,

Here is an example on the docs.

// Read from the default consumer group: $Default
string consumerGroup = EventHubConsumerClient.DefaultConsumerGroupName;

// Create a blob container client that the event processor will use 
storageClient = new BlobContainerClient(blobStorageConnectionString, blobContainerName);

// Create an event processor client to process events in the event hub
processor = new EventProcessorClient(storageClient, consumerGroup, ehubNamespaceConnectionString, eventHubName);

// Register handlers for processing events and handling errors
processor.ProcessEventAsync  = ProcessEventHandler;
processor.ProcessErrorAsync  = ProcessErrorHandler;

// Start the processing
await processor.StartProcessingAsync();

CodePudding user response:

You can enable "capture" on the eventhub and persist the streamed events to a storage account of your choice. Please check below for more details.

https://learn.microsoft.com/en-us/azure/event-hubs/event-hubs-capture-overview

  • Related