如何从Azure Event Hub获取数据?

6tqwzwtp  于 2022-11-17  发布在  其他
关注(0)|答案(2)|浏览(163)

我正在探索使用Azure Event Hub作为事件消费者。
所以我的.NET应用程序将事件发送到Azure事件中心。事件中心默认有4个分区。
我希望将事件存储在Azure Blob存储中,并将其传递给另一个.NET应用程序。
这个问题是要问-Azure事件中心是否能够将事件推送到blob和我的.NET应用程序,或者订阅者(blob和.NET应用程序)是否需要从Azure事件中心分区中提取数据?
或者我的.NET订阅者需要从Azure blob中提取事件吗?

ebdffaop

ebdffaop1#

您需要使用.Net创建一个接收器,
下面是一个关于文档的示例。

// 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();
szqfcxe2

szqfcxe22#

您可以在eventhub上启用“捕获”,并将流处理的事件保存到您选择的存储帐户。请查看下面的详细信息。
https://learn.microsoft.com/en-us/azure/event-hubs/event-hubs-capture-overview

相关问题