Skip to content

Commit 6225233

Browse files
Merge pull request #301310 from TimShererWithAquent/us439212-05
Freshness Edit: Azure Messaging Service (5 of 10)
2 parents 716c798 + 5027e34 commit 6225233

File tree

9 files changed

+101
-85
lines changed

9 files changed

+101
-85
lines changed

articles/event-hubs/event-hubs-node-get-started-send.md

Lines changed: 47 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
---
2-
title: Send or receive events using JavaScript
3-
description: This article provides a walkthrough for creating a JavaScript application that sends/receives events to/from Azure Event Hubs.
2+
title: 'Quickstart: Send or receive events using JavaScript'
3+
description: This article provides a walkthrough for creating JavaScript applications that send or receive events to and from Azure Event Hubs.
44
ms.topic: quickstart
5-
ms.date: 04/05/2024
5+
ms.date: 06/16/2025
66
ms.devlang: javascript
77
ms.custom: devx-track-js, mode-api, passwordless-js
88
#customer intent: As a JavaScript developer, I want to learn how to send events to an event hub and receive events from the event hub using C#.
99
---
1010

1111
# Quickstart: Send events to or receive events from event hubs by using JavaScript
12-
In this Quickstart, you learn how to send events to and receive events from an event hub using the **@azure/event-hubs** npm package.
1312

13+
In this Quickstart, you learn how to send events to and receive events from an event hub using the **@azure/event-hubs** npm package.
1414

15-
## Prerequisites
16-
If you're new to Azure Event Hubs, see [Event Hubs overview](event-hubs-about.md) before you do this quickstart.
15+
If you're new to Azure Event Hubs, see [Event Hubs overview](event-hubs-about.md) before you begin.
1716

18-
To complete this quickstart, you need the following prerequisites:
17+
## Prerequisites
1918

20-
- **Microsoft Azure subscription**. To use Azure services, including Azure Event Hubs, you need a subscription. If you don't have an existing Azure account, you can sign up for a [free trial](https://azure.microsoft.com/free/).
21-
- Node.js LTS. Download the latest [long-term support (LTS) version](https://nodejs.org).
22-
- Visual Studio Code (recommended) or any other integrated development environment (IDE).
23-
- **Create an Event Hubs namespace and an event hub**. The first step is to use the [Azure portal](https://portal.azure.com) to create a namespace of type Event Hubs, and obtain the management credentials your application needs to communicate with the event hub. To create a namespace and an event hub, follow the procedure in [this article](event-hubs-create.md).
19+
- Microsoft Azure subscription. To use Azure services, including Azure Event Hubs, you need a subscription. If you don't have an Azure account, sign up for a [free trial](https://azure.microsoft.com/free/).
20+
- Node.js LTS. Download the latest [long-term support (LTS) version](https://nodejs.org).
21+
- Visual Studio Code (recommended) or any other integrated development environment (IDE).
22+
- Create an Event Hubs namespace and an event hub. Use the [Azure portal](https://portal.azure.com) to create a namespace of type Event Hubs Get the management credentials that your application needs to communicate with the event hub. For more information, see [Create an event hub using Azure portal](event-hubs-create.md).
2423

2524
### Install npm packages to send events
26-
To install the [Node Package Manager (npm) package for Event Hubs](https://www.npmjs.com/package/@azure/event-hubs), open a command prompt that has *npm* in its path, change the directory
27-
to the folder where you want to keep your samples.
25+
26+
To install the [Node Package Manager (npm) package for Event Hubs](https://www.npmjs.com/package/@azure/event-hubs), open a Command Prompt window that has `npm` in its path. Change the directory to the folder where you want to keep your samples.
2827

2928
### [Passwordless (Recommended)](#tab/passwordless)
3029

@@ -53,14 +52,15 @@ npm install @azure/event-hubs
5352

5453
In this section, you create a JavaScript application that sends events to an event hub.
5554

56-
1. Open your favorite editor, such as [Visual Studio Code](https://code.visualstudio.com).
57-
1. Create a file called *send.js*, and paste the following code into it:
55+
1. Open a text editor, such as [Visual Studio Code](https://code.visualstudio.com).
56+
1. Create a file called *send.js*. Paste the following code into it:
5857

5958
## [Passwordless (Recommended)](#tab/passwordless)
6059

6160
In the code, use real values to replace the following placeholders:
62-
* `EVENT HUBS NAMESPACE NAME`
63-
* `EVENT HUB NAME`
61+
62+
- `EVENT HUBS NAMESPACE NAME`
63+
- `EVENT HUB NAME`
6464

6565
```javascript
6666
const { EventHubProducerClient } = require("@azure/event-hubs");
@@ -102,8 +102,9 @@ In this section, you create a JavaScript application that sends events to an eve
102102
## [Connection String](#tab/connection-string)
103103

104104
In the code, use real values to replace the following placeholders:
105-
* `EVENT HUB NAME`
106-
* `EVENT HUBS NAMESPACE CONNECTION STRING`
105+
106+
- `EVENT HUB NAME`
107+
- `EVENT HUBS NAMESPACE CONNECTION STRING`
107108

108109
```javascript
109110
const { EventHubProducerClient } = require("@azure/event-hubs");
@@ -138,35 +139,45 @@ In this section, you create a JavaScript application that sends events to an eve
138139

139140
---
140141

141-
1. Run `node send.js` to execute this file. This command sends a batch of three events to your event hub. If you're using the Passwordless (Azure Active Directory's Role-based Access Control) authentication, you might want to run `az login` and sign into Azure using the account that was added to the Azure Event Hubs Data Owner role.
142-
1. In the Azure portal, verify that the event hub received the messages. Refresh the page to update the chart. It might take a few seconds for it to show that the messages are received.
142+
1. To run the application, use this command:
143143

144-
[![Verify that the event hub received the messages](./media/node-get-started-send/verify-messages-portal.png)](./media/node-get-started-send/verify-messages-portal.png#lightbox)
144+
```bash
145+
node send.js
146+
```
145147

146-
> [!NOTE]
147-
> For the complete source code, including additional informational comments, go to the [GitHub sendEvents.js page](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/event-hubs/samples/v5/javascript/sendEvents.js).
148+
The command sends a batch of three events to your event hub.
149+
150+
If you're using the passwordless (Microsoft Entra ID Role-based access control (RBAC)) authentication, you might need sign into Azure using the account that you added to the Azure Event Hubs Data Owner role. Use the `az login` command.
151+
152+
1. In the Azure portal, verify that the event hub received the messages. To update the chart, refresh the page. It might take a few seconds for it to show that the messages are received.
148153
154+
:::image type="content" source="./media/node-get-started-send/verify-messages-portal.png" alt-text="Screenshot shows the Overview page where you can verify that the event hub received the message." lightbox="./media/node-get-started-send/verify-messages-portal.png":::
155+
156+
157+
> [!NOTE]
158+
> For more information and the complete source code, see [GitHub sendEvents.js page](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/event-hubs/samples/v5/javascript/sendEvents.js).
149159
150160
## Receive events
161+
151162
In this section, you receive events from an event hub by using an Azure Blob storage checkpoint store in a JavaScript application. It performs metadata checkpoints on received messages at regular intervals in an Azure Storage blob. This approach makes it easy to continue receiving messages later from where you left off.
152163
153164
[!INCLUDE [storage-checkpoint-store-recommendations](./includes/storage-checkpoint-store-recommendations.md)]
154165
155-
156166
### Create an Azure storage account and a blob container
157-
To create an Azure storage account and a blob container in it, do the following actions:
167+
168+
To create an Azure storage account with a blob container:
158169
159170
1. [Create an Azure storage account](../storage/common/storage-account-create.md?tabs=azure-portal)
160-
2. [Create a blob container in the storage account](../storage/blobs/storage-quickstart-blobs-portal.md#create-a-container)
161-
3. Authenticate to the blob container
171+
1. [Create a blob container in the storage account](../storage/blobs/storage-quickstart-blobs-portal.md#create-a-container)
172+
1. Authenticate to the blob container
162173
163174
## [Passwordless (Recommended)](#tab/passwordless)
164175
165176
[!INCLUDE [event-hub-storage-assign-roles](../../includes/passwordless/event-hub/event-hub-storage-assign-roles.md)]
166177
167178
## [Connection String](#tab/connection-string)
168179
169-
[Get the connection string to the storage account](../storage/common/storage-configure-connection-string.md).
180+
Get the connection string to the storage account. See [Configure Azure Storage connection strings](../storage/common/storage-configure-connection-string.md).
170181
171182
Note the connection string and the container name. You use them in the code to receive events.
172183
@@ -199,12 +210,13 @@ npm install @azure/eventhubs-checkpointstore-blob
199210

200211
### Write code to receive events
201212

202-
1. Open your favorite editor, such as [Visual Studio Code](https://code.visualstudio.com).
203-
1. Create a file called *receive.js*, and paste the following code into it:
213+
1. Open a text editor, such as [Visual Studio Code](https://code.visualstudio.com).
214+
1. Create a file called *receive.js*. Paste the following code into it:
204215

205216
### [Passwordless (Recommended)](#tab/passwordless)
206217

207218
In the code, use real values to replace the following placeholders:
219+
208220
- `EVENT HUBS NAMESPACE NAME`
209221
- `EVENT HUB NAME`
210222
- `STORAGE ACCOUNT NAME`
@@ -281,8 +293,8 @@ npm install @azure/eventhubs-checkpointstore-blob
281293
282294
### [Connection String](#tab/connection-string)
283295
284-
285296
In the code, use real values to replace the following placeholders:
297+
286298
- `EVENT HUBS NAMESPACE CONNECTION STRING`
287299
- `EVENT HUB NAME`
288300
- `STORAGE CONNECTION STRING`
@@ -346,8 +358,7 @@ npm install @azure/eventhubs-checkpointstore-blob
346358
347359
---
348360
349-
350-
1. Run `node receive.js` in a command prompt to execute this file. The window should display messages about received events.
361+
1. To run this code, use the command `node receive.js`. The window display messages about received events.
351362
352363
```bash
353364
C:\Self Study\Event Hubs\JavaScript>node receive.js
@@ -357,15 +368,15 @@ npm install @azure/eventhubs-checkpointstore-blob
357368
```
358369
359370
> [!NOTE]
360-
> For the complete source code, including additional informational comments, go to the [GitHub receiveEventsUsingCheckpointStore.js page](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/eventhubs-checkpointstore-blob/samples/v1/javascript/receiveEventsUsingCheckpointStore.js).
371+
> For the complete source code, including informational comments, see [receiveEventsUsingCheckpointStore.js](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/eventhubs-checkpointstore-blob/samples/v1/javascript/receiveEventsUsingCheckpointStore.js).
361372
362373
The receiver program receives events from all the partitions of the default consumer group in the event hub.
363374
364375
## Clean up resources
376+
365377
Delete the resource group that has the Event Hubs namespace or delete only the namespace if you want to keep the resource group.
366378
367379
## Related content
368-
Check out these samples on GitHub:
369380
370381
- [JavaScript samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/eventhub/event-hubs/samples/v5/javascript)
371382
- [TypeScript samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/eventhub/event-hubs/samples/v5/typescript)

articles/event-hubs/includes/storage-checkpoint-store-recommendations.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ description: Provides recommendations when using Azure Blob Storage as a checkpo
44
author: spelluru
55
ms.service: azure-event-hubs
66
ms.topic: include
7-
ms.date: 02/15/2024
7+
ms.date: 06/16/2025
88
ms.author: spelluru
99
ms.custom: "include file"
1010
---
1111

12-
Follow these recommendations when using Azure Blob Storage as a checkpoint store:
12+
Follow these recommendations when you use Azure Blob Storage as a checkpoint store:
1313

1414
- Use a separate container for each consumer group. You can use the same storage account, but use one container per each group.
15-
- Don't use the container for anything else, and don't use the storage account for anything else.
16-
- Storage account should be in the same region as the deployed application is located in. If the application is on-premises, try to choose the closest region possible.
15+
- Don't use the storage account for anything else.
16+
- Don't use the container for anything else.
17+
- Create the storage account in the same region as the deployed application. If the application is on-premises, try to choose the closest region possible.
1718

1819
On the **Storage account** page in the Azure portal, in the **Blob service** section, ensure that the following settings are disabled.
1920

2021
- Hierarchical namespace
2122
- Blob soft delete
2223
- Versioning
23-
10.1 KB
Loading
-41.6 KB
Loading

0 commit comments

Comments
 (0)