Skip to content

Commit 59178c3

Browse files
Merge pull request #223907 from spelluru/docs-editor/event-hubs-dotnet-standard-get-1673627280
SB quickstart: No need to press any key to close the program
2 parents ca74b82 + 2768a69 commit 59178c3

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

articles/event-hubs/event-hubs-dotnet-standard-getstarted-send.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ This section shows you how to create a .NET Core console application to send eve
6565
```
6666
6767
---
68-
6968
### Authenticate the app to Azure
7069
7170
[!INCLUDE [event-hub-passwordless-template-tabbed](../../includes/passwordless/event-hub/event-hub-passwordless-template-tabbed.md)]
@@ -84,7 +83,6 @@ Here are the important steps from the code:
8483
1. Sends the batch of messages to the event hub using the [EventHubProducerClient.SendAsync](/dotnet/api/azure.messaging.eventhubs.producer.eventhubproducerclient.sendasync) method.
8584
8685
In the code sample below, replace the `<EVENT_HUB_NAMESPACE>` and `<HUB_NAME>` placeholder values for the `EventHubProducerClient` parameters.
87-
8886
```csharp
8987
using Azure.Identity;
9088
using Azure.Messaging.EventHubs;
@@ -176,7 +174,6 @@ finally
176174
}
177175
```
178176
---
179-
180177
5. Build the project, and ensure that there are no errors.
181178
6. Run the program and wait for the confirmation message.
182179

@@ -194,12 +191,14 @@ finally
194191
This section shows how to write a .NET Core console application that receives events from an event hub using an event processor. The event processor simplifies receiving events from event hubs by managing persistent checkpoints and parallel receptions from those event hubs. An event processor is associated with a specific event Hub and a consumer group. It receives events from multiple partitions in the event hub, passing them to a handler delegate for processing using code that you provide.
195192

196193

194+
197195
> [!WARNING]
198196
> If you run this code on **Azure Stack Hub**, you will experience runtime errors unless you target a specific Storage API version. That's because the Event Hubs SDK uses the latest available Azure Storage API available in Azure that may not be available on your Azure Stack Hub platform. Azure Stack Hub may support a different version of Storage Blob SDK than those typically available on Azure. If you are using Azure Blob Storage as a checkpoint store, check the [supported Azure Storage API version for your Azure Stack Hub build](/azure-stack/user/azure-stack-acs-differences?#api-version) and target that version in your code.
199197
>
200198
> For example, If you are running on Azure Stack Hub version 2005, the highest available version for the Storage service is version 2019-02-02. By default, the Event Hubs SDK client library uses the highest available version on Azure (2019-07-07 at the time of the release of the SDK). In this case, besides following steps in this section, you will also need to add code to target the Storage service API version 2019-02-02. For an example on how to target a specific Storage API version, see [this sample on GitHub](https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/eventhub/Azure.Messaging.EventHubs.Processor/samples/).
201199
202200

201+
203202
### Create an Azure Storage Account and a blob container
204203
In this quickstart, you use Azure Storage as the checkpoint store. Follow these steps to create an Azure Storage account.
205204

@@ -210,15 +209,13 @@ In this quickstart, you use Azure Storage as the checkpoint store. Follow these
210209
## [Passwordless](#tab/passwordless)
211210

212211
[!INCLUDE [event-hub-storage-assign-roles](../../includes/passwordless/event-hub/event-hub-storage-assign-roles.md)]
213-
214212
## [Connection String](#tab/connection-string)
215213

216214
[Get the connection string to the storage account](../storage/common/storage-configure-connection-string.md)
217215

218216
Note down the connection string and the container name. You'll use them in the receive code.
219217

220218
---
221-
222219
### Create a project for the receiver
223220

224221
1. In the Solution Explorer window, right-click the **EventHubQuickStart** solution, point to **Add**, and select **New Project**.
@@ -252,7 +249,6 @@ Note down the connection string and the container name. You'll use them in the r
252249
```
253250

254251
---
255-
256252
### Update the code
257253

258254
Replace the contents of **Program.cs** with the following code:
@@ -264,8 +260,8 @@ Here are the important steps from the code:
264260
1. Creates an [EventProcessorClient](/dotnet/api/azure.messaging.eventhubs.eventprocessorclient) object using the event hub namespace and the event hub name. You need to build [BlobContainerClient](/dotnet/api/azure.storage.blobs.blobcontainerclient) object for the container in the Azure storage you created earlier.
265261
1. Specifies handlers for the [ProcessEventAsync](/dotnet/api/azure.messaging.eventhubs.eventprocessorclient.processeventasync) and [ProcessErrorAsync](/dotnet/api/azure.messaging.eventhubs.eventprocessorclient.processerrorasync) events of the [EventProcessorClient](/dotnet/api/azure.messaging.eventhubs.eventprocessorclient) object.
266262
1. Starts processing events by invoking the [StartProcessingAsync](/dotnet/api/azure.messaging.eventhubs.eventprocessorclient.startprocessingasync) on the [EventProcessorClient](/dotnet/api/azure.messaging.eventhubs.eventprocessorclient) object.
267-
1. When user presses a key to end the processing, invokes the [StopProcessingAsync](/dotnet/api/azure.messaging.eventhubs.eventprocessorclient.stopprocessingasync) on the [EventProcessorClient](/dotnet/api/azure.messaging.eventhubs.eventprocessorclient) object.
268-
263+
1. Stops processing events after 30 seconds by invoking [StopProcessingAsync](/dotnet/api/azure.messaging.eventhubs.eventprocessorclient.stopprocessingasync) on the [EventProcessorClient](/dotnet/api/azure.messaging.eventhubs.eventprocessorclient) object.
264+
269265
In the code sample below, replace the `<STORAGE_ACCOUNT_NAME>` and `<BLOB_CONTAINER_NAME>` placeholder values for the `BlobContainerClient` URI. Replace the `<EVENT_HUB_NAMESPACE>` and `<HUB_NAME>` placeholder values for the `EventProcessorClient` as well.
270266

271267
```csharp
@@ -329,8 +325,8 @@ Here are the important steps from the code:
329325
1. Creates an [EventProcessorClient](/dotnet/api/azure.messaging.eventhubs.eventprocessorclient) object using the primary connection string to the namespace and the event hub. You need to build [BlobContainerClient](/dotnet/api/azure.storage.blobs.blobcontainerclient) object for the container in the Azure storage you created earlier.
330326
1. Specifies handlers for the [ProcessEventAsync](/dotnet/api/azure.messaging.eventhubs.eventprocessorclient.processeventasync) and [ProcessErrorAsync](/dotnet/api/azure.messaging.eventhubs.eventprocessorclient.processerrorasync) events of the [EventProcessorClient](/dotnet/api/azure.messaging.eventhubs.eventprocessorclient) object.
331327
1. Starts processing events by invoking the [StartProcessingAsync](/dotnet/api/azure.messaging.eventhubs.eventprocessorclient.startprocessingasync) on the [EventProcessorClient](/dotnet/api/azure.messaging.eventhubs.eventprocessorclient) object.
332-
1. When user presses a key to end the processing, invokes the [StopProcessingAsync](/dotnet/api/azure.messaging.eventhubs.eventprocessorclient.stopprocessingasync) on the [EventProcessorClient](/dotnet/api/azure.messaging.eventhubs.eventprocessorclient) object.
333-
328+
1. Stops processing events after 30 seconds by invoking [StopProcessingAsync](/dotnet/api/azure.messaging.eventhubs.eventprocessorclient.stopprocessingasync) on the [EventProcessorClient](/dotnet/api/azure.messaging.eventhubs.eventprocessorclient) object.
329+
334330
In the code sample below, replace the `<AZURE_STORAGE_CONNECTION_STRING>` and `<BLOB_CONTAINER_NAME>` placeholder values for the `BlobContainerClient` URI. Replace the `<EVENT_HUB_NAMESPACE_CONNECTION_STRING>` and `<HUB_NAME>` placeholder values for the `EventProcessorClient` as well.
335331

336332
```csharp
@@ -383,7 +379,6 @@ Task ProcessErrorHandler(ProcessErrorEventArgs eventArgs)
383379
```
384380

385381
---
386-
387382
1. Build the project, and ensure that there are no errors.
388383

389384
> [!NOTE]
@@ -416,3 +411,4 @@ See the following tutorial:
416411

417412
> [!div class="nextstepaction"]
418413
> [Tutorial: Visualize data anomalies in real-time events sent to Azure Event Hubs](event-hubs-tutorial-visualize-anomalies.md)
414+

0 commit comments

Comments
 (0)