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 JavaScript developer, I want to learn how to send events to an event hub and receive events from the event hub using C#.
9
9
---
10
10
11
11
# 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.
13
12
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.
14
14
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.
17
16
18
-
To complete this quickstart, you need the following prerequisites:
17
+
## Prerequisites
19
18
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).
24
23
25
24
### 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.
@@ -138,35 +139,45 @@ In this section, you create a JavaScript application that sends events to an eve
138
139
139
140
---
140
141
141
-
1. Run `node send.js` to execute thisfile. This command sends a batch of three events to your eventhub. 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:
143
143
144
-
[](./media/node-get-started-send/verify-messages-portal.png#lightbox)
144
+
```bash
145
+
node send.js
146
+
```
145
147
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.
148
153
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).
149
159
150
160
## Receive events
161
+
151
162
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.
[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).
170
181
171
182
Note the connection string and the container name. You use them in the code to receive events.
> 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).
361
372
362
373
The receiver program receives events from all the partitions of the default consumer group in the event hub.
363
374
364
375
## Clean up resources
376
+
365
377
Delete the resource group that has the Event Hubs namespace or delete only the namespace if you want to keep the resource group.
Copy file name to clipboardExpand all lines: articles/event-hubs/includes/storage-checkpoint-store-recommendations.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,20 +4,20 @@ description: Provides recommendations when using Azure Blob Storage as a checkpo
4
4
author: spelluru
5
5
ms.service: azure-event-hubs
6
6
ms.topic: include
7
-
ms.date: 02/15/2024
7
+
ms.date: 06/16/2025
8
8
ms.author: spelluru
9
9
ms.custom: "include file"
10
10
---
11
11
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:
13
13
14
14
- 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.
17
18
18
19
On the **Storage account** page in the Azure portal, in the **Blob service** section, ensure that the following settings are disabled.
0 commit comments