Skip to content

Commit 1334962

Browse files
Freshness.
1 parent fd710f2 commit 1334962

File tree

5 files changed

+57
-47
lines changed

5 files changed

+57
-47
lines changed

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

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,20 @@ ms.custom: devx-track-js, mode-api, passwordless-js
1010

1111
# Quickstart: Send events to or receive events from event hubs by using JavaScript
1212

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.
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-
17-
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.
1816

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

21-
- **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/).
22-
- Node.js LTS. Download the latest [long-term support (LTS) version](https://nodejs.org).
23-
- Visual Studio Code (recommended) or any other integrated development environment (IDE).
24-
- **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. For more information, see [Create an event hub using Azure portal](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).
2523

2624
### Install npm packages to send events
2725

28-
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 to the folder where you want to keep your samples.
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.
2927

3028
### [Passwordless (Recommended)](#tab/passwordless)
3129

@@ -54,8 +52,8 @@ npm install @azure/event-hubs
5452

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

57-
1. Open your favorite editor, such as [Visual Studio Code](https://code.visualstudio.com).
58-
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:
5957

6058
## [Passwordless (Recommended)](#tab/passwordless)
6159

@@ -141,7 +139,16 @@ In this section, you create a JavaScript application that sends events to an eve
141139

142140
---
143141

144-
1. To run this file, enter `node send.js`. This command sends a batch of three events to your event hub. If you're using the passwordless (Microsoft Entra ID Role-based access control (RBAC)) 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. To run the application, use this command:
143+
144+
```bash
145+
node send.js
146+
```
147+
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+
145152
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.
146153
147154
:::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":::
@@ -158,7 +165,7 @@ In this section, you receive events from an event hub by using an Azure Blob sto
158165
159166
### Create an Azure storage account and a blob container
160167
161-
To create an Azure storage account and a blob container in it, do the following actions:
168+
To create an Azure storage account with a blob container:
162169
163170
1. [Create an Azure storage account](../storage/common/storage-account-create.md?tabs=azure-portal)
164171
1. [Create a blob container in the storage account](../storage/blobs/storage-quickstart-blobs-portal.md#create-a-container)
@@ -203,8 +210,8 @@ npm install @azure/eventhubs-checkpointstore-blob
203210

204211
### Write code to receive events
205212

206-
1. Open your favorite editor, such as [Visual Studio Code](https://code.visualstudio.com).
207-
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:
208215

209216
### [Passwordless (Recommended)](#tab/passwordless)
210217

@@ -351,7 +358,7 @@ npm install @azure/eventhubs-checkpointstore-blob
351358
352359
---
353360
354-
1. To run this file, enter `node receive.js`. 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.
355362
356363
```bash
357364
C:\Self Study\Event Hubs\JavaScript>node receive.js
@@ -361,7 +368,7 @@ npm install @azure/eventhubs-checkpointstore-blob
361368
```
362369
363370
> [!NOTE]
364-
> For the complete source code, including additional 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).
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).
365372
366373
The receiver program receives events from all the partitions of the default consumer group in the event hub.
367374
@@ -371,7 +378,5 @@ Delete the resource group that has the Event Hubs namespace or delete only the n
371378
372379
## Related content
373380
374-
Check out these samples on GitHub:
375-
376381
- [JavaScript samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/eventhub/event-hubs/samples/v5/javascript)
377382
- [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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ 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-

includes/passwordless/event-hub/event-hub-assign-roles.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ ms.author: alexwolf
1010
ms.custom: include file
1111
---
1212

13-
When developing locally, make sure that the user account that connects to Azure Event Hubs has the correct permissions. You need the [Azure Event Hubs Data Owner](../../../articles/role-based-access-control/built-in-roles.md#azure-event-hubs-data-owner) role in order to send and receive messages. To assign yourself this role, you need the User Access Administrator role, or another role that includes the `Microsoft.Authorization/roleAssignments/write` action. You can assign Azure RBAC roles to a user using the Azure portal, Azure CLI, or Azure PowerShell. For more information about the available scopes for role assignments, see [Understand scope for Azure RBAC](../../../articles/role-based-access-control/scope-overview.md) page.
13+
When you develop locally, make sure that the user account that connects to Azure Event Hubs has the correct permissions. You need the [Azure Event Hubs Data Owner](../../../articles/role-based-access-control/built-in-roles.md#azure-event-hubs-data-owner) role to send and receive messages. To assign yourself this role, you need the User Access Administrator role, or another role that includes the `Microsoft.Authorization/roleAssignments/write` action. You can assign Azure RBAC roles to a user using the Azure portal, Azure CLI, or Azure PowerShell. For more information, see [Understand scope for Azure RBAC](../../../articles/role-based-access-control/scope-overview.md) page.
1414

1515
The following example assigns the `Azure Event Hubs Data Owner` role to your user account, which provides full access to Azure Event Hubs resources. In a real scenario, follow the [Principle of Least Privilege](../../../articles/active-directory/develop/secure-least-privileged-access.md) to give users only the minimum permissions needed for a more secure production environment.
1616

1717
### Azure built-in roles for Azure Event Hubs
1818

19-
For Azure Event Hubs, the management of namespaces and all related resources through the Azure portal and the Azure resource management API is already protected using the Azure RBAC model. Azure provides the below Azure built-in roles for authorizing access to an Event Hubs namespace:
19+
For Azure Event Hubs, the management of namespaces and all related resources through the Azure portal and the Azure resource management API is already protected using the Azure RBAC model. Azure provides the following built-in roles for authorizing access to an Event Hubs namespace:
2020

21-
- [Azure Event Hubs Data Owner](../../../articles/role-based-access-control/built-in-roles.md#azure-event-hubs-data-owner): Enables data access to Event Hubs namespace and its entities (queues, topics, subscriptions, and filters)
21+
- [Azure Event Hubs Data Owner](../../../articles/role-based-access-control/built-in-roles.md#azure-event-hubs-data-owner): Enables data access to Event Hubs namespace and its entities (queues, topics, subscriptions, and filters).
2222
- [Azure Event Hubs Data Sender](../../../articles/role-based-access-control/built-in-roles.md#azure-event-hubs-data-sender): Use this role to give the sender access to Event Hubs namespace and its entities.
2323
- [Azure Event Hubs Data Receiver](../../../articles/role-based-access-control/built-in-roles.md#azure-event-hubs-data-receiver): Use this role to give the receiver access to Event Hubs namespace and its entities.
2424

@@ -35,27 +35,27 @@ If you want to create a custom role, see [Rights required for Event Hubs operati
3535

3636
1. On the **Access control (IAM)** page, select the **Role assignments** tab.
3737

38-
1. Select **+ Add** from the top menu and then **Add role assignment** from the resulting drop-down menu.
38+
1. Select **+ Add** from the top menu. Then select **Add role assignment**.
3939

4040
:::image type="content" source="media/event-hub-assign-roles/add-role.png" alt-text="Screenshot showing how to assign a role.":::
4141

4242
1. Use the search box to filter the results to the desired role. For this example, search for `Azure Event Hubs Data Owner` and select the matching result. Then choose **Next**.
4343

44-
1. Under **Assign access to**, select **User, group, or service principal**, and then choose **+ Select members**.
44+
1. Under **Assign access to**, select **User, group, or service principal**. Then choose **+ Select members**.
4545

46-
1. In the dialog, search for your Microsoft Entra username (usually your *user@domain* email address) and then choose **Select** at the bottom of the dialog.
46+
1. In the dialog, search for your Microsoft Entra username (usually your *user@domain* email address). Choose **Select** at the bottom of the dialog.
4747

48-
1. Select **Review + assign** to go to the final page, and then **Review + assign** again to complete the process.
48+
1. Select **Review + assign** to go to the final page. Select **Review + assign** again to complete the process.
4949

5050
### [Azure CLI](#tab/roles-azure-cli)
5151

52-
To assign a role at the resource level using the Azure CLI, you first must retrieve the resource ID using the `az eventhubs namespace show` command. You can filter the output properties using the `--query` parameter.
52+
To assign a role at the resource level using the Azure CLI, first get the resource ID using the `az eventhubs namespace show` command. You can filter the output properties using the `--query` parameter.
5353

5454
```azurecli
55-
az eventhubs namespace show -g '<your-event-hub-resource-group>' -n '<your-event-hub-name> --query id
55+
az eventhubs namespace show -g '<your-event-hub-resource-group>' -n '<your-event-hub-name>' --query id
5656
```
5757

58-
Copy the output `Id` from the preceding command. You can then assign roles using the [az role](/cli/azure/role) command of the Azure CLI.
58+
Copy the output `Id` from the preceding command. You can then assign roles using the [az role](/cli/azure/role) command.
5959

6060
```azurecli
6161
az role assignment create --assignee "<user@domain>" \
@@ -65,13 +65,13 @@ az role assignment create --assignee "<user@domain>" \
6565

6666
### [PowerShell](#tab/roles-powershell)
6767

68-
To assign a role at the resource level using Azure PowerShell, you first must retrieve the resource ID using the `Get-AzResource` command.
68+
To assign a role at the resource level using Azure PowerShell, first get the resource ID using the `Get-AzResource` command.
6969

7070
```azurepowershell
7171
Get-AzResource -ResourceGroupName "<your-event-hub-resource-group>" -Name "<your-event-hub-name>"
7272
```
7373

74-
Copy the `Id` value from the preceding command output. You can then assign roles using the [New-AzRoleAssignment](/powershell/module/az.resources/new-azroleassignment) command in PowerShell.
74+
Copy the `Id` value from the preceding command output. You can then assign roles using the [New-AzRoleAssignment](/powershell/module/az.resources/new-azroleassignment) command.
7575

7676
```azurepowershell
7777
New-AzRoleAssignment -SignInName <user@domain> `

includes/passwordless/event-hub/event-hub-passwordless-template-tabbed-basic.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ ms.author: diberry
1010
ms.custom: include file
1111
---
1212

13-
This quickstart shows you two ways of connecting to Azure Event Hubs: passwordless and connection string. The first option shows you how to use your security principal in Microsoft Entra ID and role-based access control (RBAC) to connect to an Event Hubs namespace. You don't need to worry about having hard-coded connection strings in your code, in a configuration file, or in secure storage like Azure Key Vault. The second option shows you how to use a connection string to connect to an Event Hubs namespace. If you're new to Azure, you might find the connection string option easier to follow. We recommend using the passwordless option in real-world applications and production environments. For more information, see [Service Bus authentication and authorization](../../../articles/service-bus-messaging/service-bus-authentication-and-authorization.md). For more information, see [Passwordless connections for Azure services](/azure/developer/intro/passwordless-overview).
13+
This quickstart shows you two ways of connecting to Azure Event Hubs:
14+
15+
- *Passwordless*. Use your security principal in Microsoft Entra ID and role-based access control (RBAC) to connect to an Event Hubs namespace. You don't need to worry about having hard-coded connection strings in your code, in a configuration file, or in secure storage like Azure Key Vault.
16+
- *connection string*. Use a connection string to connect to an Event Hubs namespace. If you're new to Azure, you might find the connection string option easier to follow.
17+
18+
We recommend using the passwordless option in real-world applications and production environments. For more information, see [Service Bus authentication and authorization](../../../articles/service-bus-messaging/service-bus-authentication-and-authorization.md) and [Passwordless connections for Azure services](/azure/developer/intro/passwordless-overview).
1419

1520
## [Passwordless (Recommended)](#tab/passwordless)
1621

@@ -24,7 +29,7 @@ This quickstart shows you two ways of connecting to Azure Event Hubs: passwordle
2429

2530
## Get the connection string
2631

27-
Creating a new namespace automatically generates an initial Shared Access Signature (SAS) policy with primary and secondary keys and connection strings that each grant full control over all aspects of the namespace. See [Event Hubs authentication and authorization](../../../articles/service-bus-messaging/service-bus-authentication-and-authorization.md) for information about how to create rules with more constrained rights for regular senders and receivers.
32+
Creating a new namespace automatically generates an initial Shared Access Signature (SAS) policy with primary and secondary keys and connection strings that each grant full control over all aspects of the namespace. For information about how to create rules with more constrained rights for regular senders and receivers, see [Event Hubs authentication and authorization](../../../articles/service-bus-messaging/service-bus-authentication-and-authorization.md).
2833

2934
A client can use the connection string to connect to the Event Hubs namespace. To copy the primary connection string for your namespace, follow these steps:
3035

0 commit comments

Comments
 (0)