You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#customer intent: As a .NET developer, I want to learn how to send events to an event hub and receive events from the event hub using C#.
9
10
---
10
11
11
12
# Quickstart: Send events to and receive events from Azure Event Hubs using .NET
12
13
In this quickstart, you learn how to send events to an event hub and then receive those events from the event hub using the **Azure.Messaging.EventHubs** .NET library.
13
14
14
15
> [!NOTE]
15
-
> Quickstarts are for you to quickly ramp up on the service. If you are already familiar with the service, you may want to see .NET samples for Event Hubs in our .NET SDK repository on GitHub: [Event Hubs samples on GitHub](https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/eventhub/Azure.Messaging.EventHubs/samples), [Event processor samples on GitHub](https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/eventhub/Azure.Messaging.EventHubs.Processor/samples).
16
+
> Quickstarts are for you to quickly ramp up on the service. If you are already familiar with the service, you might want to see .NET samples for Event Hubs in our .NET SDK repository on GitHub: [Event Hubs samples on GitHub](https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/eventhub/Azure.Messaging.EventHubs/samples), [Event processor samples on GitHub](https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/eventhub/Azure.Messaging.EventHubs.Processor/samples).
16
17
17
18
## Prerequisites
18
19
If you're new to Azure Event Hubs, see [Event Hubs overview](event-hubs-about.md) before you go through this quickstart.
@@ -185,7 +186,10 @@ This section shows you how to create a .NET Core console application to send eve
185
186
```csharp
186
187
A batch of 3 events has been published.
187
188
```
188
-
4. On the **Event Hubs Namespace** page in the Azure portal, you see three incoming messages in the **Messages** chart. Refresh the page to update the chart if needed. It may take a few seconds for it to show that the messages have been received.
189
+
190
+
> [!IMPORTANT]
191
+
> If you are using the Passwordless (Azure Active Directory's Role-based Access Control) authentication, select **Tools**, then select **Options**. In the **Options** window, expand **Azure Service Authentication**, and select **Account Selection**. Confirm that you are using the account that was added to the **Azure Event Hubs Data Owner** role on the Event Hubs namespace.
192
+
4. On the **Event Hubs Namespace** page in the Azure portal, you see three incoming messages in the **Messages** chart. Refresh the page to update the chart if needed. It might take a few seconds for it to show that the messages have been received.
189
193
190
194
:::image type="content" source="./media/getstarted-dotnet-standard-send-v2/verify-messages-portal.png" alt-text="Image of the Azure portal page to verify that the event hub received the events" lightbox="./media/getstarted-dotnet-standard-send-v2/verify-messages-portal.png":::
191
195
@@ -212,7 +216,7 @@ In this quickstart, you use Azure Storage as the checkpoint store. Follow these
212
216
213
217
[Get the connection string to the storage account](../storage/common/storage-account-get-info.md#get-a-connection-string-for-the-storage-account)
214
218
215
-
Note down the connection string and the container name. You use them in the receive code.
219
+
Note down the connection string and the container name. You use them in the code to receive events from the event hub.
216
220
217
221
---
218
222
### Create a project for the receiver
@@ -365,7 +369,6 @@ Replace the contents of **Program.cs** with the following code:
365
369
{
366
370
// Write the body of the event to the console window
@@ -374,7 +377,6 @@ Replace the contents of **Program.cs** with the following code:
374
377
// Write details about the error to the console window
375
378
Console.WriteLine($"\tPartition '{eventArgs.PartitionId}': an unhandled exception was encountered. This was not expected to happen.");
376
379
Console.WriteLine(eventArgs.Exception.Message);
377
-
Console.ReadLine();
378
380
return Task.CompletedTask;
379
381
}
380
382
```
@@ -386,15 +388,15 @@ Replace the contents of **Program.cs** with the following code:
386
388
> [!NOTE]
387
389
> For the complete source code with more informational comments, see [this file on the GitHub](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/eventhub/Azure.Messaging.EventHubs.Processor/samples/Sample01_HelloWorld.md).
388
390
3. Run the receiver application.
389
-
4. You should see a message that the events have been received.
391
+
4. You should see a message that the events have been received. Press ENTER after you see a received event message.
390
392
391
393
```bash
392
394
Received event: Event 1
393
395
Received event: Event 2
394
396
Received event: Event 3
395
397
```
396
398
These events are the three events you sent to the event hub earlier by running the sender program.
397
-
5. In the Azure portal, you can verify that there are three outgoing messages, which Event Hubs sent to the receiving application. Refresh the page to update the chart. It may take a few seconds for it to show that the messages have been received.
399
+
5. In the Azure portal, you can verify that there are three outgoing messages, which Event Hubs sent to the receiving application. Refresh the page to update the chart. It might take a few seconds for it to show that the messages have been received.
398
400
399
401
:::image type="content" source="./media/getstarted-dotnet-standard-send-v2/verify-messages-portal-2.png" alt-text="Image of the Azure portal page to verify that the event hub sent events to the receiving app" lightbox="./media/getstarted-dotnet-standard-send-v2/verify-messages-portal-2.png":::
400
402
@@ -405,8 +407,6 @@ Azure Schema Registry of Event Hubs provides a centralized repository for managi
405
407
406
408
To learn more, see [Validate schemas with Event Hubs SDK](schema-registry-dotnet-send-receive-quickstart.md).
407
409
408
-
## Clean up resources
409
-
Delete the resource group that has the Event Hubs namespace or delete only the namespace if you want to keep the resource group.
410
410
411
411
## Samples and reference
412
412
This quick start provides step-by-step instructions to implement a scenario of sending a batch of events to an event hub and then receiving them. For more samples, select the following links.
@@ -417,7 +417,10 @@ This quick start provides step-by-step instructions to implement a scenario of s
417
417
418
418
For complete .NET library reference, see our [SDK documentation](/dotnet/api/overview/azure/event-hubs).
419
419
420
-
## Next steps
420
+
## Clean up resources
421
+
Delete the resource group that has the Event Hubs namespace or delete only the namespace if you want to keep the resource group.
0 commit comments