Skip to content

Commit 1f01a32

Browse files
committed
Update
1 parent de69c98 commit 1f01a32

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

articles/event-hubs/event-hubs-capture-python.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: 'Quickstart: Read Azure Event Hubs captured data (Python)'
33
description: This quickstart shows you how to write Python code to capture data that's sent to an event hub and read the captured event data from an Azure storage account.
44
ms.topic: quickstart
5-
ms.date: 03/14/2023
5+
ms.date: 02/07/2024
66
ms.devlang: python
77
ms.custom: mode-api, devx-track-python
88
---
@@ -24,11 +24,7 @@ In this quickstart, you:
2424
2525
## Prerequisites
2626

27-
- Python with PIP and the following packages installed. The code in this article has been tested against these versions.
28-
- Python 3.7
29-
- azure-eventhub 5.2.0
30-
- azure-storage-blob 12.6.0
31-
- avro-python3 1.10.1
27+
- Python 3.8 or later, with pip installed and updated.
3228
- An Azure subscription. If you don't have one, [create a free account](https://azure.microsoft.com/free/) before you begin.
3329
- An active Event Hubs namespace and event hub.
3430
[Create an Event Hubs namespace and an event hub in the namespace](event-hubs-create.md). Record the name of the Event Hubs namespace, the name of the event hub, and the primary access key for the namespace. To get the access key, see [Get an Event Hubs connection string](event-hubs-get-connection-string.md#azure-portal). The default key name is *RootManageSharedAccessKey*. For this quickstart, you need only the primary key. You don't need the connection string.
@@ -72,7 +68,13 @@ In this section, you create a Python script that sends 200 events (10 devices *
7268
event_data_batch = producer.create_batch() # Create a batch. You will add events to the batch later.
7369
for dev in devices:
7470
# Create a dummy reading.
75-
reading = {'id': dev, 'timestamp': str(datetime.datetime.now(datetime.UTC)), 'uv': random.random(), 'temperature': random.randint(70, 100), 'humidity': random.randint(70, 100)}
71+
reading = {
72+
'id': dev,
73+
'timestamp': str(datetime.datetime.utcnow()),
74+
'uv': random.random(),
75+
'temperature': random.randint(70, 100),
76+
'humidity': random.randint(70, 100)
77+
}
7678
s = json.dumps(reading) # Convert the reading into a JSON string.
7779
event_data_batch.add(EventData(s)) # Add event data to the batch.
7880
producer.send_batch(event_data_batch) # Send the batch of events to the event hub.
@@ -159,13 +161,6 @@ In this example, the captured data is stored in Azure Blob storage. The script i
159161
pip install azure-eventhub
160162
pip install avro-python3
161163
```
162-
163-
> [!NOTE]
164-
> The code in this article has been tested against these versions.
165-
> - Python 3.7
166-
> - azure-eventhub 5.2.0
167-
> - azure-storage-blob 12.6.0
168-
> - avro-python3 1.10.1
169164
2. Change your directory to the directory where you saved *sender.py* and *capturereader.py*, and run this command:
170165

171166
```

0 commit comments

Comments
 (0)