Skip to content

Commit fc08d23

Browse files
Merge pull request #265647 from spelluru/python38
Min version 2.8
2 parents ccc41d0 + 1f01a32 commit fc08d23

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
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
```

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Send or receive events from Azure Event Hubs using Python
33
description: This article provides a walkthrough for creating a Python application that sends/receives events to/from Azure Event Hubs.
44
ms.topic: quickstart
5-
ms.date: 01/08/2023
5+
ms.date: 02/07/2024
66
ms.devlang: python
77
ms.custom: mode-api, passwordless-python, devx-track-python
88
---
@@ -16,7 +16,7 @@ If you're new to Azure Event Hubs, see [Event Hubs overview](event-hubs-about.md
1616
To complete this quickstart, you need the following prerequisites:
1717

1818
- **Microsoft Azure subscription**. To use Azure services, including Azure Event Hubs, you need a subscription. If you don't have an existing Azure account, sign up for a [free trial](https://azure.microsoft.com/free/).
19-
- Python 3.7 or later, with pip installed and updated.
19+
- Python 3.8 or later, with pip installed and updated.
2020
- Visual Studio Code (recommended) or any other integrated development environment (IDE).
2121
- **Create an Event Hubs namespace and an event hub**. The first step is to use the [Azure portal](https://portal.azure.com) to create an Event Hubs namespace, and obtain the management credentials that 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).
2222

0 commit comments

Comments
 (0)