Closed
Description
openedon Dec 1, 2020
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.Data
to 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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment