Skip to content

Commit c84a163

Browse files
committed
Update docs metadata
1 parent 10b6d03 commit c84a163

2 files changed

Lines changed: 92 additions & 48 deletions

File tree

docs-ref-services/latest/eventhub-readme.md

Lines changed: 86 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
title: Azure Event Hubs client library for Python
3-
keywords: Azure, python, SDK, API, azure-eventhub, event-hubs
4-
ms.date: 06/11/2024
3+
keywords: Azure, python, SDK, API, azure-eventhub, azure-event-hubs
4+
ms.date: 10/02/2024
55
ms.topic: reference
66
ms.devlang: python
7-
ms.service: event-hubs
7+
ms.service: azure-event-hubs
88
---
9-
# Azure Event Hubs client library for Python - version 5.12.1
9+
# Azure Event Hubs client library for Python - version 5.12.2
1010

1111

1212
Azure Event Hubs is a highly scalable publish-subscribe service that can ingest millions of events per second and stream
@@ -22,12 +22,12 @@ The Azure Event Hubs client library allows for publishing and consuming of Azure
2222
- Observe interesting operations and interactions happening within your business or other ecosystem, allowing loosely coupled systems to interact without the need to bind them together.
2323
- Receive events from one or more publishers, transform them to better meet the needs of your ecosystem, then publish the transformed events to a new stream for consumers to observe.
2424

25-
[Source code](https://github.com/Azure/azure-sdk-for-python/blob/azure-eventhub_5.12.1/sdk/eventhub/azure-eventhub/)
25+
[Source code](https://github.com/Azure/azure-sdk-for-python/blob/azure-eventhub_5.12.2/sdk/eventhub/azure-eventhub/)
2626
| [Package (PyPi)](https://pypi.org/project/azure-eventhub/)
2727
| [Package (Conda)](https://anaconda.org/microsoft/azure-eventhub/)
2828
| [API reference documentation][api_reference]
2929
| [Product documentation](/azure/event-hubs/)
30-
| [Samples](https://github.com/Azure/azure-sdk-for-python/tree/azure-eventhub_5.12.1/sdk/eventhub/azure-eventhub/samples)
30+
| [Samples](https://github.com/Azure/azure-sdk-for-python/tree/azure-eventhub_5.12.2/sdk/eventhub/azure-eventhub/samples)
3131

3232
## Getting started
3333

@@ -54,7 +54,7 @@ $ pip install azure-eventhub
5454

5555
Interaction with Event Hubs starts with an instance of EventHubConsumerClient or EventHubProducerClient class. You need either the host name, SAS/AAD credential and event hub name or a connection string to instantiate the client object.
5656

57-
**[Create client from connection string:](https://github.com/Azure/azure-sdk-for-python/blob/azure-eventhub_5.12.1/sdk/eventhub/azure-eventhub/samples/sync_samples/connection_string_authentication.py)**
57+
**[Create client from connection string:](https://github.com/Azure/azure-sdk-for-python/blob/azure-eventhub_5.12.2/sdk/eventhub/azure-eventhub/samples/sync_samples/connection_string_authentication.py)**
5858

5959
For the Event Hubs client library to interact with an Event Hub, the easiest means is to use a connection string, which is created automatically when creating an Event Hubs namespace.
6060
If you aren't familiar with shared access policies in Azure, you may wish to follow the step-by-step guide to [get an Event Hubs connection string](/azure/event-hubs/event-hubs-get-connection-string).
@@ -63,12 +63,12 @@ If you aren't familiar with shared access policies in Azure, you may wish to fol
6363
`Endpoint=sb://<yournamespace>.servicebus.windows.net/;SharedAccessKeyName=<yoursharedaccesskeyname>;SharedAccessKey=<yoursharedaccesskey>` and
6464
entity name to your Event Hub instance. You can get the connection string from the [Azure portal](/azure/event-hubs/event-hubs-get-connection-string#get-connection-string-from-the-portal).
6565

66-
**[Create client using the azure-identity library:](https://github.com/Azure/azure-sdk-for-python/blob/azure-eventhub_5.12.1/sdk/eventhub/azure-eventhub/samples/sync_samples/client_identity_authentication.py)**
66+
**[Create client using the azure-identity library:](https://github.com/Azure/azure-sdk-for-python/blob/azure-eventhub_5.12.2/sdk/eventhub/azure-eventhub/samples/sync_samples/client_identity_authentication.py)**
6767

6868
Alternately, one can use a Credential object to authenticate via AAD with the azure-identity package.
6969

7070
- This constructor demonstrated in the sample linked above takes the host name and entity name of your Event Hub instance and credential that implements the
71-
[TokenCredential](https://github.com/Azure/azure-sdk-for-python/blob/azure-eventhub_5.12.1/sdk/core/azure-core/azure/core/credentials.py)
71+
[TokenCredential](https://github.com/Azure/azure-sdk-for-python/blob/azure-eventhub_5.12.2/sdk/core/azure-core/azure/core/credentials.py)
7272
protocol. There are implementations of the `TokenCredential` protocol available in the
7373
[azure-identity package](https://pypi.org/project/azure-identity/). The host name is of the format `<yournamespace.servicebus.windows.net>`.
7474
- To use the credential types provided by `azure-identity`, please install the package:
@@ -127,27 +127,25 @@ The following sections provide several code snippets covering some of the most c
127127

128128
Get the partition ids of an Event Hub.
129129

130-
<!-- SNIPPET:connection_string_authentication.connection_string_authentication -->
131-
132130
```python
133131
import os
134132
from azure.eventhub import EventHubConsumerClient
133+
from azure.identity import DefaultAzureCredential
135134

136-
CONNECTION_STR = os.environ["EVENT_HUB_CONN_STR"]
135+
FULLY_QUALIFIED_NAMESPACE = os.environ["EVENT_HUB_HOSTNAME"]
137136
EVENTHUB_NAME = os.environ['EVENT_HUB_NAME']
138137

139-
consumer_client = EventHubConsumerClient.from_connection_string(
140-
conn_str=CONNECTION_STR,
138+
consumer_client = EventHubConsumerClient(
139+
fully_qualified_namespace=FULLY_QUALIFIED_NAMESPACE,
141140
consumer_group='$Default',
142141
eventhub_name=EVENTHUB_NAME,
142+
credential=DefaultAzureCredential(),
143143
)
144144

145145
with consumer_client:
146146
pass # consumer_client is now ready to be used.
147147
```
148148

149-
<!-- END SNIPPET -->
150-
151149
### Publish events to an Event Hub
152150

153151
Use the `create_batch` method on `EventHubProducerClient` to create an `EventDataBatch` object which can then be sent using the `send_batch` method.
@@ -174,11 +172,17 @@ the `EventHubConsumerClient.receive` method will be of use as follows:
174172
```python
175173
import logging
176174
from azure.eventhub import EventHubConsumerClient
175+
from azure.identity import DefaultAzureCredential
177176

178-
connection_str = '<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>'
177+
fully_qualified_namespace = '<< EVENT HUBS FULLY QUALIFIED NAMESPACE >>'
179178
consumer_group = '<< CONSUMER GROUP >>'
180179
eventhub_name = '<< NAME OF THE EVENT HUB >>'
181-
client = EventHubConsumerClient.from_connection_string(connection_str, consumer_group, eventhub_name=eventhub_name)
180+
client = EventHubConsumerClient(
181+
fully_qualified_namespace=fully_qualified_namespace,
182+
eventhub_name=eventhub_name,
183+
consumer_group=consumer_group,
184+
credential=DefaultAzureCredential(),
185+
)
182186

183187
logger = logging.getLogger("azure.eventhub")
184188
logging.basicConfig(level=logging.INFO)
@@ -204,11 +208,17 @@ triggers the callback on a batch of events, attempting to receive a number at a
204208
```python
205209
import logging
206210
from azure.eventhub import EventHubConsumerClient
211+
from azure.identity import DefaultAzureCredential
207212

208-
connection_str = '<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>'
213+
fully_qualified_namespace = '<< EVENT HUBS FULLY QUALIFIED NAMESPACE >>'
209214
consumer_group = '<< CONSUMER GROUP >>'
210215
eventhub_name = '<< NAME OF THE EVENT HUB >>'
211-
client = EventHubConsumerClient.from_connection_string(connection_str, consumer_group, eventhub_name=eventhub_name)
216+
client = EventHubConsumerClient(
217+
fully_qualified_namespace=fully_qualified_namespace,
218+
eventhub_name=eventhub_name,
219+
consumer_group=consumer_group,
220+
credential=DefaultAzureCredential(),
221+
)
212222

213223
logger = logging.getLogger("azure.eventhub")
214224
logging.basicConfig(level=logging.INFO)
@@ -232,11 +242,11 @@ Use the `create_batch` method on `EventHubProducer` to create an `EventDataBatch
232242
Events may be added to the `EventDataBatch` using the `add` method until the maximum batch size limit in bytes has been reached.
233243
```python
234244
import asyncio
235-
from azure.eventhub.aio import EventHubProducerClient # The package name suffixed with ".aio" for async
245+
from azure.eventhub.aio import EventHubProducerClient # The package name suffixed with ".aio" for async
236246
from azure.eventhub import EventData
247+
from azure.identity.aio import DefaultAzureCredential
237248

238-
connection_str = '<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>'
239-
consumer_group = '<< CONSUMER GROUP >>'
249+
fully_qualified_namespace = '<< EVENT HUBS FULLY QUALIFIED NAMESPACE >>'
240250
eventhub_name = '<< NAME OF THE EVENT HUB >>'
241251

242252
async def create_batch(client):
@@ -250,7 +260,11 @@ async def create_batch(client):
250260
return event_data_batch
251261

252262
async def send():
253-
client = EventHubProducerClient.from_connection_string(connection_str, eventhub_name=eventhub_name)
263+
client = EventHubProducerClient(
264+
fully_qualified_namespace=fully_qualified_namespace,
265+
eventhub_name=eventhub_name,
266+
credential=DefaultAzureCredential(),
267+
)
254268
batch_data = await create_batch(client)
255269
async with client:
256270
await client.send_batch(batch_data)
@@ -269,8 +283,9 @@ aio, one would need the following:
269283
import logging
270284
import asyncio
271285
from azure.eventhub.aio import EventHubConsumerClient
286+
from azure.identity.aio import DefaultAzureCredential
272287

273-
connection_str = '<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>'
288+
fully_qualified_namespace = '<< EVENT HUBS FULLY QUALIFIED NAMESPACE >>'
274289
consumer_group = '<< CONSUMER GROUP >>'
275290
eventhub_name = '<< NAME OF THE EVENT HUB >>'
276291

@@ -282,7 +297,12 @@ async def on_event(partition_context, event):
282297
await partition_context.update_checkpoint(event)
283298

284299
async def receive():
285-
client = EventHubConsumerClient.from_connection_string(connection_str, consumer_group, eventhub_name=eventhub_name)
300+
client = EventHubConsumerClient(
301+
fully_qualified_namespace=fully_qualified_namespace,
302+
eventhub_name=eventhub_name,
303+
consumer_group=consumer_group,
304+
credential=DefaultAzureCredential(),
305+
)
286306
async with client:
287307
await client.receive(
288308
on_event=on_event,
@@ -305,8 +325,9 @@ the same within asyncio as follows:
305325
import logging
306326
import asyncio
307327
from azure.eventhub.aio import EventHubConsumerClient
328+
from azure.identity.aio import DefaultAzureCredential
308329

309-
connection_str = '<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>'
330+
fully_qualified_namespace = '<< EVENT HUBS FULLY QUALIFIED NAMESPACE >>'
310331
consumer_group = '<< CONSUMER GROUP >>'
311332
eventhub_name = '<< NAME OF THE EVENT HUB >>'
312333

@@ -318,7 +339,12 @@ async def on_event_batch(partition_context, events):
318339
await partition_context.update_checkpoint()
319340

320341
async def receive_batch():
321-
client = EventHubConsumerClient.from_connection_string(connection_str, consumer_group, eventhub_name=eventhub_name)
342+
client = EventHubConsumerClient(
343+
fully_qualified_namespace=fully_qualified_namespace,
344+
eventhub_name=eventhub_name,
345+
consumer_group=consumer_group,
346+
credential=DefaultAzureCredential(),
347+
)
322348
async with client:
323349
await client.receive_batch(
324350
on_event_batch=on_event_batch,
@@ -350,8 +376,8 @@ In the below example, we create an instance of `EventHubConsumerClient` and use
350376
to [create an Azure Storage account](/azure/storage/common/storage-quickstart-create-account?tabs=azure-portal)
351377
and a [Blob Container](/azure/storage/blobs/storage-quickstart-blobs-portal#create-a-container) to run the code.
352378

353-
[Azure Blob Storage Checkpoint Store Async](https://github.com/Azure/azure-sdk-for-python/blob/azure-eventhub_5.12.1/sdk/eventhub/azure-eventhub-checkpointstoreblob-aio)
354-
and [Azure Blob Storage Checkpoint Store Sync](https://github.com/Azure/azure-sdk-for-python/blob/azure-eventhub_5.12.1/sdk/eventhub/azure-eventhub-checkpointstoreblob)
379+
[Azure Blob Storage Checkpoint Store Async](https://github.com/Azure/azure-sdk-for-python/blob/azure-eventhub_5.12.2/sdk/eventhub/azure-eventhub-checkpointstoreblob-aio)
380+
and [Azure Blob Storage Checkpoint Store Sync](https://github.com/Azure/azure-sdk-for-python/blob/azure-eventhub_5.12.2/sdk/eventhub/azure-eventhub-checkpointstoreblob)
355381
are one of the `CheckpointStore` implementations we provide that applies Azure Blob Storage as the persistent store.
356382

357383

@@ -360,11 +386,12 @@ import asyncio
360386

361387
from azure.eventhub.aio import EventHubConsumerClient
362388
from azure.eventhub.extensions.checkpointstoreblobaio import BlobCheckpointStore
389+
from azure.identity.aio import DefaultAzureCredential
363390

364-
connection_str = '<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>'
391+
fully_qualified_namespace = '<< EVENT HUBS FULLY QUALIFIED NAMESPACE >>'
365392
consumer_group = '<< CONSUMER GROUP >>'
366393
eventhub_name = '<< NAME OF THE EVENT HUB >>'
367-
storage_connection_str = '<< CONNECTION STRING FOR THE STORAGE >>'
394+
blob_account_url = '<< STORAGE ACCOUNT URL >>'
368395
container_name = '<<NAME OF THE BLOB CONTAINER>>'
369396

370397
async def on_event(partition_context, event):
@@ -378,11 +405,16 @@ async def receive(client):
378405
)
379406

380407
async def main():
381-
checkpoint_store = BlobCheckpointStore.from_connection_string(storage_connection_str, container_name)
382-
client = EventHubConsumerClient.from_connection_string(
383-
connection_str,
384-
consumer_group,
408+
checkpoint_store = BlobCheckpointStore(
409+
blob_account_url=blob_account_url,
410+
container_name=container_name,
411+
credential=DefaultAzureCredential()
412+
)
413+
client = EventHubConsumerClient(
414+
fully_qualified_namespace=fully_qualified_namespace,
385415
eventhub_name=eventhub_name,
416+
credential=DefaultAzureCredential(),
417+
consumer_group=consumer_group,
386418
checkpoint_store=checkpoint_store, # For load balancing and checkpoint. Leave None for no load balancing
387419
)
388420
async with client:
@@ -413,11 +445,11 @@ client = EventHubConsumerClient.from_connection_string(connection_str, consumer_
413445
partition_ids = client.get_partition_ids()
414446
```
415447
- Programmatically retrieve the built-in Event Hubs compatible endpoint.
416-
Refer to [IoT Hub Connection String Sample](https://github.com/Azure/azure-sdk-for-python/blob/azure-eventhub_5.12.1/sdk/eventhub/azure-eventhub/samples/async_samples/iot_hub_connection_string_receive_async.py).
448+
Refer to [IoT Hub Connection String Sample](https://github.com/Azure/azure-sdk-for-python/blob/azure-eventhub_5.12.2/sdk/eventhub/azure-eventhub/samples/async_samples/iot_hub_connection_string_receive_async.py).
417449

418450
## Troubleshooting
419451

420-
See the `azure-eventhub` [troubleshooting guide](https://github.com/Azure/azure-sdk-for-python/blob/azure-eventhub_5.12.1/sdk/eventhub/azure-eventhub/TROUBLESHOOTING.md) for details on how to diagnose various failure scenarios.
452+
See the `azure-eventhub` [troubleshooting guide](https://github.com/Azure/azure-sdk-for-python/blob/azure-eventhub_5.12.2/sdk/eventhub/azure-eventhub/TROUBLESHOOTING.md) for details on how to diagnose various failure scenarios.
421453

422454
### Logging
423455

@@ -446,7 +478,7 @@ consumer = EventHubConsumerClient(..., logging_enable=True)
446478

447479
### More sample code
448480

449-
Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-python/blob/azure-eventhub_5.12.1/sdk/eventhub/azure-eventhub/samples) directory for detailed examples of how to use this library to send and receive events to/from Event Hubs.
481+
Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-python/blob/azure-eventhub_5.12.2/sdk/eventhub/azure-eventhub/samples) directory for detailed examples of how to use this library to send and receive events to/from Event Hubs.
450482

451483
### Documentation
452484

@@ -473,16 +505,24 @@ $ pip install uamqp
473505

474506
```python
475507
from azure.eventhub import EventHubProducerClient, EventHubConsumerClient
508+
from azure.identity import DefaultAzureCredential
476509

477-
connection_str = '<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>'
510+
fully_qualified_namespace = '<< EVENT HUBS FULLY QUALIFIED NAMESPACE >>'
478511
consumer_group = '<< CONSUMER GROUP >>'
479512
eventhub_name = '<< NAME OF THE EVENT HUB >>'
480513

481-
client = EventHubProducerClient.from_connection_string(
482-
connection_str, eventhub_name=eventhub_name, uamqp_transport=True
514+
client = EventHubProducerClient(
515+
fully_qualified_namespace=fully_qualified_namespace,
516+
eventhub_name=eventhub_name,
517+
credential=DefaultAzureCredential(),
518+
uamqp_transport=True
483519
)
484-
client = EventHubConsumerClient.from_connection_string(
485-
connection_str, consumer_group, eventhub_name=eventhub_name, uamqp_transport=True
520+
client = EventHubConsumerClient(
521+
fully_qualified_namespace=fully_qualified_namespace,
522+
eventhub_name=eventhub_name,
523+
credential=DefaultAzureCredential(),
524+
consumer_group=consumer_group,
525+
uamqp_transport=True
486526
)
487527
```
488528

@@ -515,8 +555,8 @@ For more information see the [Code of Conduct FAQ](https://opensource.microsoft.
515555
[avro]: https://avro.apache.org/
516556
[api_reference]: /python/api/overview/azure/eventhub-readme
517557
[schemaregistry_service]: https://aka.ms/schemaregistry
518-
[schemaregistry_repo]: https://github.com/Azure/azure-sdk-for-python/tree/azure-eventhub_5.12.1/sdk/schemaregistry/azure-schemaregistry
519-
[schemaregistry_avroencoder_repo]: https://github.com/Azure/azure-sdk-for-python/tree/azure-eventhub_5.12.1/sdk/schemaregistry/azure-schemaregistry-avroencoder
558+
[schemaregistry_repo]: https://github.com/Azure/azure-sdk-for-python/tree/azure-eventhub_5.12.2/sdk/schemaregistry/azure-schemaregistry
559+
[schemaregistry_avroencoder_repo]: https://github.com/Azure/azure-sdk-for-python/tree/azure-eventhub_5.12.2/sdk/schemaregistry/azure-schemaregistry-avroencoder
520560

521561
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python/sdk/eventhub/azure-eventhub/README.png)
522562

metadata/latest/azure-eventhub.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"Name": "azure-eventhub",
3-
"Version": "5.12.1",
3+
"Version": "5.12.2",
44
"DevVersion": null,
55
"DirectoryPath": "sdk/eventhub/azure-eventhub",
66
"ServiceDirectory": "eventhub",
@@ -10,7 +10,11 @@
1010
"SdkType": "client",
1111
"IsNewSdk": true,
1212
"ArtifactName": "azure-eventhub",
13-
"ReleaseStatus": "2024-06-11",
13+
"ReleaseStatus": "2024-10-02",
14+
"IncludedForValidation": false,
15+
"AdditionalValidationPackages": [
16+
""
17+
],
1418
"Namespaces": [
1519
"azure.eventhub"
1620
],

0 commit comments

Comments
 (0)