Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] EventHub .NET Sample. Wrong instructions in README #17263

Closed
rido-min opened this issue Dec 1, 2020 · 3 comments
Closed

[BUG] EventHub .NET Sample. Wrong instructions in README #17263

rido-min opened this issue Dec 1, 2020 · 3 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. Docs Event Hubs
Milestone

Comments

@rido-min
Copy link
Member

rido-min commented 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.

  1. Add main NuGet dotnet add package Azure.Messaging.EventHubs
  2. Update AMQP to workaround: Possible incompatibility with .NET 5.0 azure-amqp#165
  3. Add dotnet add package System.Memory.Data to be able to use BinaryData
  4. 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;
    }
}
@ghost ghost added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Dec 1, 2020
@jsquire jsquire self-assigned this Dec 1, 2020
@jsquire jsquire added Client This issue points to a problem in the data-plane of the library. Docs Event Hubs labels Dec 1, 2020
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Dec 1, 2020
@jsquire
Copy link
Member

jsquire commented Dec 1, 2020

Hi @rido-min. Thank you for your feedback. Looks like we missed updating the samples README to reference the 5.3.0-beta.4 package. I'll get that patched up.

@jsquire
Copy link
Member

jsquire commented Dec 10, 2020

Fixed by #17315

@jsquire jsquire closed this as completed Dec 10, 2020
@devedse
Copy link

devedse commented Jan 7, 2021

@github-actions github-actions bot locked and limited conversation to collaborators Mar 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. Docs Event Hubs
Projects
None yet
Development

No branches or pull requests

3 participants