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
Copy file name to clipboardExpand all lines: articles/event-hubs/get-started-node-send-v2.md
+31-31Lines changed: 31 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ ms.author: spelluru
12
12
13
13
---
14
14
15
-
# Send events to or receive events from Azure Event Hubs using Node.js
15
+
# Send events to or receive events from Azure Event Hubs using Node.js
16
16
17
17
Azure Event Hubs is a Big Data streaming platform and event ingestion service that can receive and process millions of events per second. Event Hubs can process and store events, data, or telemetry produced by distributed software and devices. Data sent to an event hub can be transformed and stored using any real-time analytics provider or batching/storage adapters. For detailed overview of Event Hubs, see [Event Hubs overview](event-hubs-about.md) and [Event Hubs features](event-hubs-features.md).
console.log("A batch of three events have been sent to the event hub");
83
83
}
84
84
85
85
main().catch((err) => {
86
86
console.log("Error occurred: ", err);
87
87
});
88
88
```
89
-
3. Don't forget to replace the **connection string** and the **event hub name** values in the code.
89
+
3. Don't forget to replace the **connection string** and the **event hub name** values in the code.
90
90
5. Run the command `node send.js` to execute this file. This will send a batch of three events to your event hub
91
-
6. In the Azure portal, you can verify that the event hub has received the messages. Switch to **Messages** view in the **Metrics** section. Refresh the page to update the chart. It may take a few seconds for it to show that the messages have been received.
91
+
6. In the Azure portal, you can verify that the event hub has received the messages. Switch to **Messages** view in the **Metrics** section. Refresh the page to update the chart. It may take a few seconds for it to show that the messages have been received.
92
92
93
93
[](./media/getstarted-dotnet-standard-send-v2/verify-messages-portal.png#lightbox)
94
94
95
95
> [!NOTE]
96
96
> For the complete source code with more informational comments, see [this file on the GitHub](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/eventhub/event-hubs/samples/javascript/sendEvents.js)
97
97
98
-
Congratulations! You have now sent events to an event hub.
98
+
Congratulations! You have now sent events to an event hub.
99
99
100
100
101
-
## Receive events
101
+
## Receive events
102
102
This section shows how to receive events from an event hub by using an Azure Blob checkpoint store in a Node.js application. It checkpoints metadata on received messages at regular intervals in an Azure Storage Blob. This approach makes it easy to continue receiving messages from where you left off at a later time.
103
103
104
104
### Create an Azure Storage and a blob container
105
-
Follow these steps to create an Azure Storage account a blob container in it.
105
+
Follow these steps to create an Azure Storage account a blob container in it.
106
106
107
-
1. [Create an Azure Storage account](../storage/common/storage-quickstart-create-account.md?tabs=azure-portal)
107
+
1. [Create an Azure Storage account](../storage/common/storage-account-create.md?tabs=azure-portal)
108
108
2. [Create a blob container](../storage/blobs/storage-quickstart-blobs-portal.md#create-a-container)
109
109
3. [Get the connection string to the storage account](../storage/common/storage-configure-connection-string.md?#view-and-copy-a-connection-string)
110
110
111
-
Note down connection string and the container name. You will use them in the receive code.
111
+
Note down connection string and the container name. You will use them in the receive code.
112
112
113
113
### Write code to receive events
114
114
115
-
1. Open your favorite editor, such as [Visual Studio Code](https://code.visualstudio.com).
116
-
2. Create a file called `receive.js` and paste the following code into it. See code comments for details.
115
+
1. Open your favorite editor, such as [Visual Studio Code](https://code.visualstudio.com).
116
+
2. Create a file called `receive.js` and paste the following code into it. See code comments for details.
@@ -158,17 +158,17 @@ Follow these steps to create an Azure Storage account a blob container in it.
158
158
}, 30000);
159
159
});
160
160
}
161
-
161
+
162
162
main().catch((err) => {
163
163
console.log("Error occurred: ", err);
164
164
});
165
165
```
166
-
3. Don't forget to specify the **following values**in the code:
166
+
3. Don't forget to specify the **following values**in the code:
167
167
- Connection string to the Event Hubs namespace
168
168
- Name of the event hub
169
169
- Connection string to the Azure Storage account
170
170
- Name of the blob container
171
-
5. Then run the command `node receive.js`in a command prompt to execute thisfile. You should see the messages about received events in the window.
171
+
5. Then run the command `node receive.js`in a command prompt to execute thisfile. You should see the messages about received events in the window.
172
172
173
173
> [!NOTE]
174
174
> For the complete source code with more informational comments, see [this file on the GitHub](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/eventhub/eventhubs-checkpointstore-blob/samples/receiveEventsUsingCheckpointStore.js).
@@ -179,4 +179,4 @@ Congratulations! You have now received events from event hub. The receiver progr
Copy file name to clipboardExpand all lines: articles/event-hubs/get-started-python-send-v2.md
+30-30Lines changed: 30 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ ms.author: spelluru
16
16
17
17
Azure Event Hubs is a Big Data streaming platform and event ingestion service, capable of receiving and processing millions of events per second. Event Hubs can process and store events, data, or telemetry produced by distributed software and devices. Data sent to an event hub can be transformed and stored using any real-time analytics provider or batching/storage adapters. For detailed overview of Event Hubs, see [Event Hubs overview](event-hubs-about.md) and [Event Hubs features](event-hubs-features.md).
18
18
19
-
This tutorial describes how to create Python applications to send events to or receive events from an event hub.
19
+
This tutorial describes how to create Python applications to send events to or receive events from an event hub.
20
20
21
21
> [!IMPORTANT]
22
22
> This quickstart uses version 5 of the Azure Event Hubs Python SDK. For a quick start that uses the old version 1 of the Python SDK, see [this article](event-hubs-python-get-started-send.md). If you are using version 1 of the SDK, we recommend that you migrate your code to the latest version. For details, see the [migration guide](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/eventhub/azure-eventhub/migration_guide.md).
@@ -27,53 +27,53 @@ This tutorial describes how to create Python applications to send events to or r
27
27
To complete this tutorial, you need the following prerequisites:
28
28
29
29
- An Azure subscription. If you don't have one, [create a free account](https://azure.microsoft.com/free/) before you begin.
30
-
- An active Event Hubs namespace and event hub, created by following the instructions at [Quickstart: Create an event hub using Azure portal](event-hubs-create.md). Make a note of the namespace and event hub names to use later in this walkthrough.
31
-
- The shared access key name and primary key value for your Event Hubs namespace. Get the access key name and value by following the instructions at [Get connection string](event-hubs-get-connection-string.md#get-connection-string-from-the-portal). The default access key name is **RootManageSharedAccessKey**. Copy the key name and the primary key value to use later in this walkthrough.
30
+
- An active Event Hubs namespace and event hub, created by following the instructions at [Quickstart: Create an event hub using Azure portal](event-hubs-create.md). Make a note of the namespace and event hub names to use later in this walkthrough.
31
+
- The shared access key name and primary key value for your Event Hubs namespace. Get the access key name and value by following the instructions at [Get connection string](event-hubs-get-connection-string.md#get-connection-string-from-the-portal). The default access key name is **RootManageSharedAccessKey**. Copy the key name and the primary key value to use later in this walkthrough.
32
32
- Python 2.7, and 3.5 or later, with `pip` installed and updated.
33
-
- The Python package for Event Hubs. To install the package, run this command in a command prompt that has Python in its path:
34
-
33
+
- The Python package for Event Hubs. To install the package, run this command in a command prompt that has Python in its path:
34
+
35
35
```cmd
36
36
pip install azure-eventhub
37
37
```
38
38
39
-
Install this package for receiving the events using an Azure Blob storage as the checkpoint store.
39
+
Install this package for receiving the events using an Azure Blob storage as the checkpoint store.
40
40
41
41
```cmd
42
42
pip install azure-eventhub-checkpointstoreblobaio
43
43
```
44
44
45
45
## Send events
46
-
In this section, you create a Python script to send events to the event hub you created earlier.
46
+
In this section, you create a Python script to send events to the event hub you created earlier.
47
47
48
48
1. Open your favorite Python editor, such as [Visual Studio Code](https://code.visualstudio.com/)
49
-
2. Create a script called **send.py**. This script sends a batch of events to the event hub you created earlier.
50
-
3. Paste the following code into send.py. See the code comments for details.
49
+
2. Create a script called **send.py**. This script sends a batch of events to the event hub you created earlier.
50
+
3. Paste the following code into send.py. See the code comments for details.
51
51
52
52
```python
53
53
import asyncio
54
54
from azure.eventhub.aio import EventHubProducerClient
55
55
from azure.eventhub import EventData
56
-
56
+
57
57
async def run():
58
58
# create a producer client to send messages to the event hub
59
-
# specify connection string to your event hubs namespace and
59
+
# specify connection string to your event hubs namespace and
@@ -150,10 +150,10 @@ To run the script, open a command prompt that has Python in its path, and then r
150
150
python send.py
151
151
```
152
152
153
-
You should see the messages that were sent to the event hub in the receiver window.
153
+
You should see the messages that were sent to the event hub in the receiver window.
154
154
155
155
156
156
## Next steps
157
157
In this quickstart, you have sent and receive events asynchronously. To learn how to send and receive events synchronously, see samples in [this location](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/eventhub/azure-eventhub/samples/sync_samples).
158
158
159
-
You can find all the samples (both sync and async) on the GitHub [here](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/eventhub/azure-eventhub/samples).
159
+
You can find all the samples (both sync and async) on the GitHub [here](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/eventhub/azure-eventhub/samples).
0 commit comments