-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Closed
Labels
ClientThis issue is related to a non-management packageThis issue is related to a non-management packageDocsEvent Hubs
Milestone
Description
Following https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/eventhub/Azure.Messaging.EventHubs/samples/Sample01_HelloWorld.md I found missing instructions:
Expected behavior
I can follow and complete the tutorial
Actual behavior (include Exception or Stack Trace)
The sample code does not compile
I fixed by following the next steps.
- Add main NuGet
dotnet add package Azure.Messaging.EventHubs - Update AMQP to workaround: Possible incompatibility with .NET 5.0 azure-amqp#165
- Add
dotnet add package System.Memory.Datato be able to useBinaryData - Update code to avoid using
partitionEvent.Data.EventBody
I update the code from
await foreach (PartitionEvent partitionEvent in consumer.ReadEventsAsync(cancellationSource.Token))
{
eventDataRead.Add(partitionEvent.Data.EventBody.ToString());
if (eventDataRead.Count >= maximumEvents)
{
break;
}
}to:
await foreach (PartitionEvent partitionEvent in consumer.ReadEventsAsync(cancellationSource.Token))
{
var data = BinaryData.FromBytes(partitionEvent.Data.Body);
eventDataRead.Add(data.ToString());
if (eventDataRead.Count >= maximumEvents)
{
break;
}
}rnarayana
Metadata
Metadata
Assignees
Labels
ClientThis issue is related to a non-management packageThis issue is related to a non-management packageDocsEvent Hubs