From f35fc4174414610e3a72742aa8beb7b5b3d2908b Mon Sep 17 00:00:00 2001 From: Yunhao Ling Date: Thu, 3 Oct 2019 16:51:43 -0700 Subject: [PATCH 1/6] Update docs --- sdk/eventhub/azure-eventhubs/HISTORY.md | 15 +++++++++++++-- sdk/eventhub/azure-eventhubs/setup.py | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/sdk/eventhub/azure-eventhubs/HISTORY.md b/sdk/eventhub/azure-eventhubs/HISTORY.md index f0577a7640d9..91a5477ff655 100644 --- a/sdk/eventhub/azure-eventhubs/HISTORY.md +++ b/sdk/eventhub/azure-eventhubs/HISTORY.md @@ -1,10 +1,21 @@ # Release History -## 5.0.0b4 (2019-XX-XX) +## 5.0.0b4 (2019-10-08) **New features** -- Support for tracing #7153 +- Added support for tracing (issue #7153). +- Added the capability of `EventHubConsumer` to track last enqueued event properties of the partition. + - Added new boolean type parameter`track_last_enqueued_event_properties` in method `EventHubClient.create_consumer()`. + - Added new property `last_enqueued_event_properties` of on `EventHubConsumer` which contains sequence_number, offset, enqueued_time and retrieval_time information. + - By default the capability is disabled as it will cost extra band width for transferring more information if turned on. + +**Breaking changes** + +- Removed support for IoThHub direct connection. + - [EventHubs compatible connection string](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-read-builtin) of an IotHub can be used to create EventHubClient. +- Removed parameter `exception` in method `close()` of `EventHubConsumer` and `EventHubProcuer`. +- Updated uAMQP dependency to 1.2.3 ## 5.0.0b3 (2019-09-10) diff --git a/sdk/eventhub/azure-eventhubs/setup.py b/sdk/eventhub/azure-eventhubs/setup.py index 7652ff91bdc7..288b6a37691c 100644 --- a/sdk/eventhub/azure-eventhubs/setup.py +++ b/sdk/eventhub/azure-eventhubs/setup.py @@ -68,7 +68,7 @@ packages=find_packages(exclude=exclude_packages), install_requires=[ "azure-core<2.0.0,>=1.0.0b4", - 'uamqp~=1.2.0', + 'uamqp>=1.2.3', 'azure-common~=1.1', ], extras_require={ From c2900b9693da2a8d89b69c02a92f5d130b861576 Mon Sep 17 00:00:00 2001 From: Yunhao Ling Date: Thu, 3 Oct 2019 17:31:14 -0700 Subject: [PATCH 2/6] Update iothub related description --- sdk/eventhub/azure-eventhubs/HISTORY.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sdk/eventhub/azure-eventhubs/HISTORY.md b/sdk/eventhub/azure-eventhubs/HISTORY.md index 91a5477ff655..c0a197e41ef1 100644 --- a/sdk/eventhub/azure-eventhubs/HISTORY.md +++ b/sdk/eventhub/azure-eventhubs/HISTORY.md @@ -12,10 +12,11 @@ **Breaking changes** -- Removed support for IoThHub direct connection. - - [EventHubs compatible connection string](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-read-builtin) of an IotHub can be used to create EventHubClient. +- Removed support for IoT Hub direct connection. + - [EventHubs compatible connection string](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-read-builtin) of an IotHub can be used to create `EventHubClient` and receive device-to-cloud IoT Hub messages. +- Removed support for sending EventData to IoT Hub. - Removed parameter `exception` in method `close()` of `EventHubConsumer` and `EventHubProcuer`. -- Updated uAMQP dependency to 1.2.3 +- Updated uAMQP dependency to 1.2.3. ## 5.0.0b3 (2019-09-10) From 17428352d366de60fe8cc475dffb2e19c0ce2a15 Mon Sep 17 00:00:00 2001 From: Adam Ling Date: Fri, 4 Oct 2019 11:53:33 -0700 Subject: [PATCH 3/6] Docs update --- sdk/eventhub/azure-eventhubs/HISTORY.md | 4 ++-- sdk/eventhub/azure-eventhubs/README.md | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/sdk/eventhub/azure-eventhubs/HISTORY.md b/sdk/eventhub/azure-eventhubs/HISTORY.md index c0a197e41ef1..85fc63509e55 100644 --- a/sdk/eventhub/azure-eventhubs/HISTORY.md +++ b/sdk/eventhub/azure-eventhubs/HISTORY.md @@ -5,7 +5,7 @@ **New features** - Added support for tracing (issue #7153). -- Added the capability of `EventHubConsumer` to track last enqueued event properties of the partition. +- Added the capability of tracking last enqueued event properties of the partition to `EventHubConsumer` . - Added new boolean type parameter`track_last_enqueued_event_properties` in method `EventHubClient.create_consumer()`. - Added new property `last_enqueued_event_properties` of on `EventHubConsumer` which contains sequence_number, offset, enqueued_time and retrieval_time information. - By default the capability is disabled as it will cost extra band width for transferring more information if turned on. @@ -13,7 +13,7 @@ **Breaking changes** - Removed support for IoT Hub direct connection. - - [EventHubs compatible connection string](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-read-builtin) of an IotHub can be used to create `EventHubClient` and receive device-to-cloud IoT Hub messages. + - [EventHubs compatible connection string](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-read-builtin) of an IotHub can be used to create `EventHubClient` and read properties or events from an IoT Hub. - Removed support for sending EventData to IoT Hub. - Removed parameter `exception` in method `close()` of `EventHubConsumer` and `EventHubProcuer`. - Updated uAMQP dependency to 1.2.3. diff --git a/sdk/eventhub/azure-eventhubs/README.md b/sdk/eventhub/azure-eventhubs/README.md index f456159d938f..875180de8320 100644 --- a/sdk/eventhub/azure-eventhubs/README.md +++ b/sdk/eventhub/azure-eventhubs/README.md @@ -13,7 +13,7 @@ The Azure Event Hubs client library allows for publishing and consuming of Azure - 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. - 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. -[Source code](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/eventhub/azure-eventhubs) | [Package (PyPi)](https://pypi.org/project/azure-eventhub/5.0.0b3) | [API reference documentation](https://azure.github.io/azure-sdk-for-python/ref/azure.eventhub) | [Product documentation](https://docs.microsoft.com/en-us/azure/event-hubs/) +[Source code](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/eventhub/azure-eventhubs) | [Package (PyPi)](https://pypi.org/project/azure-eventhub/5.0.0b4) | [API reference documentation](https://azure.github.io/azure-sdk-for-python/ref/azure.eventhub) | [Product documentation](https://docs.microsoft.com/en-us/azure/event-hubs/) ## Getting started @@ -119,6 +119,7 @@ The following sections provide several code snippets covering some of the most c - [Async publish events to an Event Hub](#async-publish-events-to-an-event-hub) - [Async consume events from an Event Hub](#async-consume-events-from-an-event-hub) - [Consume events using an Event Processor](#consume-events-using-an-event-processor) +- [Use EventHubClient to work with IoT Hub](#use-eventhubclient-to-work-with-iot-hub) ### Inspect an Event Hub @@ -359,6 +360,24 @@ if __name__ == '__main__': loop.run_until_complete(main()) ``` +### Use EventHubClient to work with IoT Hub + +You can use `EventHubClient` to work with IoT Hub as well. This is useful for receiving telemetry data of IoT Hub from the +linked EventHub. The associated connection string will not have send claims, hence sending events is not possible. + +- Please notice that the connection string needs to be for an + [Event Hub-compatible endpoint](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-read-builtin) + e.g. "Endpoint=sb://my-iothub-namespace-[uid].servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;EntityPath=my-iot-hub-name" + +```python +from azure.eventhub.aio import EventHubClient + +connection_str = 'Endpoint=sb://my-iothub-namespace-[uid].servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;EntityPath=my-iot-hub-name' +client = EventHubClient.from_connection_string(connection_str) + +partition_ids = client.get_partition_ids() +``` + ## Troubleshooting ### General From 4b643434212eb38728fc37603e805299e40fe681 Mon Sep 17 00:00:00 2001 From: Adam Ling Date: Fri, 4 Oct 2019 11:54:58 -0700 Subject: [PATCH 4/6] Small fix --- sdk/eventhub/azure-eventhubs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/eventhub/azure-eventhubs/README.md b/sdk/eventhub/azure-eventhubs/README.md index 875180de8320..e4fc68fd38e0 100644 --- a/sdk/eventhub/azure-eventhubs/README.md +++ b/sdk/eventhub/azure-eventhubs/README.md @@ -370,7 +370,7 @@ linked EventHub. The associated connection string will not have send claims, hen e.g. "Endpoint=sb://my-iothub-namespace-[uid].servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;EntityPath=my-iot-hub-name" ```python -from azure.eventhub.aio import EventHubClient +from azure.eventhub import EventHubClient connection_str = 'Endpoint=sb://my-iothub-namespace-[uid].servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key;EntityPath=my-iot-hub-name' client = EventHubClient.from_connection_string(connection_str) From 2e88d0465f82bf9b052e491db1f1058ede0c0dfe Mon Sep 17 00:00:00 2001 From: Adam Ling Date: Fri, 4 Oct 2019 12:02:33 -0700 Subject: [PATCH 5/6] Small fix --- sdk/eventhub/azure-eventhubs/azure/eventhub/aio/client_async.py | 2 +- .../azure-eventhubs/azure/eventhub/aio/consumer_async.py | 2 +- sdk/eventhub/azure-eventhubs/azure/eventhub/client.py | 2 +- sdk/eventhub/azure-eventhubs/azure/eventhub/consumer.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/eventhub/azure-eventhubs/azure/eventhub/aio/client_async.py b/sdk/eventhub/azure-eventhubs/azure/eventhub/aio/client_async.py index 06d117c10cd6..e679afaa1cf1 100644 --- a/sdk/eventhub/azure-eventhubs/azure/eventhub/aio/client_async.py +++ b/sdk/eventhub/azure-eventhubs/azure/eventhub/aio/client_async.py @@ -223,7 +223,6 @@ def create_consumer( :type owner_level: int :param prefetch: The message prefetch count of the consumer. Default is 300. :type prefetch: int - :type track_last_enqueued_event_properties: bool :param track_last_enqueued_event_properties: Indicates whether or not the consumer should request information on the last enqueued event on its associated partition, and track that information as events are received. When information about the partition's last enqueued event is being tracked, each event received from the @@ -231,6 +230,7 @@ def create_consumer( network bandwidth consumption that is generally a favorable trade-off when considered against periodically making requests for partition properties using the Event Hub client. It is set to `False` by default. + :type track_last_enqueued_event_properties: bool :param loop: An event loop. If not specified the default event loop will be used. :rtype: ~azure.eventhub.aio.consumer_async.EventHubConsumer diff --git a/sdk/eventhub/azure-eventhubs/azure/eventhub/aio/consumer_async.py b/sdk/eventhub/azure-eventhubs/azure/eventhub/aio/consumer_async.py index 861e88383ed6..7aff6980b9e0 100644 --- a/sdk/eventhub/azure-eventhubs/azure/eventhub/aio/consumer_async.py +++ b/sdk/eventhub/azure-eventhubs/azure/eventhub/aio/consumer_async.py @@ -58,7 +58,6 @@ def __init__( # pylint: disable=super-init-not-called :param owner_level: The priority of the exclusive consumer. An exclusive consumer will be created if owner_level is set. :type owner_level: int - :type track_last_enqueued_event_properties: bool :param track_last_enqueued_event_properties: Indicates whether or not the consumer should request information on the last enqueued event on its associated partition, and track that information as events are received. When information about the partition's last enqueued event is being tracked, each event received from the @@ -66,6 +65,7 @@ def __init__( # pylint: disable=super-init-not-called network bandwidth consumption that is generally a favorable trade-off when considered against periodically making requests for partition properties using the Event Hub client. It is set to `False` by default. + :type track_last_enqueued_event_properties: bool :param loop: An event loop. """ event_position = kwargs.get("event_position", None) diff --git a/sdk/eventhub/azure-eventhubs/azure/eventhub/client.py b/sdk/eventhub/azure-eventhubs/azure/eventhub/client.py index df7390511f6c..9a7ca85e3330 100644 --- a/sdk/eventhub/azure-eventhubs/azure/eventhub/client.py +++ b/sdk/eventhub/azure-eventhubs/azure/eventhub/client.py @@ -229,7 +229,6 @@ def create_consumer(self, consumer_group, partition_id, event_position, **kwargs :type owner_level: int :param prefetch: The message prefetch count of the consumer. Default is 300. :type prefetch: int - :type track_last_enqueued_event_properties: bool :param track_last_enqueued_event_properties: Indicates whether or not the consumer should request information on the last enqueued event on its associated partition, and track that information as events are received. When information about the partition's last enqueued event is being tracked, each event received from the @@ -237,6 +236,7 @@ def create_consumer(self, consumer_group, partition_id, event_position, **kwargs network bandwidth consumption that is generally a favorable trade-off when considered against periodically making requests for partition properties using the Event Hub client. It is set to `False` by default. + :type track_last_enqueued_event_properties: bool :rtype: ~azure.eventhub.consumer.EventHubConsumer Example: diff --git a/sdk/eventhub/azure-eventhubs/azure/eventhub/consumer.py b/sdk/eventhub/azure-eventhubs/azure/eventhub/consumer.py index dd94291a6b49..87869aaa3a7b 100644 --- a/sdk/eventhub/azure-eventhubs/azure/eventhub/consumer.py +++ b/sdk/eventhub/azure-eventhubs/azure/eventhub/consumer.py @@ -57,7 +57,6 @@ def __init__(self, client, source, **kwargs): :param owner_level: The priority of the exclusive consumer. An exclusive consumer will be created if owner_level is set. :type owner_level: int - :type track_last_enqueued_event_properties: bool :param track_last_enqueued_event_properties: Indicates whether or not the consumer should request information on the last enqueued event on its associated partition, and track that information as events are received. When information about the partition's last enqueued event is being tracked, each event received from the @@ -65,6 +64,7 @@ def __init__(self, client, source, **kwargs): network bandwidth consumption that is generally a favorable trade-off when considered against periodically making requests for partition properties using the Event Hub client. It is set to `False` by default. + :type track_last_enqueued_event_properties: bool """ event_position = kwargs.get("event_position", None) prefetch = kwargs.get("prefetch", 300) From 7f390b6ec0be12afe6e6a663ed2291ec88178933 Mon Sep 17 00:00:00 2001 From: Yunhao Ling Date: Fri, 4 Oct 2019 16:39:32 -0700 Subject: [PATCH 6/6] revert setup.py --- sdk/eventhub/azure-eventhubs/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/eventhub/azure-eventhubs/setup.py b/sdk/eventhub/azure-eventhubs/setup.py index 288b6a37691c..7652ff91bdc7 100644 --- a/sdk/eventhub/azure-eventhubs/setup.py +++ b/sdk/eventhub/azure-eventhubs/setup.py @@ -68,7 +68,7 @@ packages=find_packages(exclude=exclude_packages), install_requires=[ "azure-core<2.0.0,>=1.0.0b4", - 'uamqp>=1.2.3', + 'uamqp~=1.2.0', 'azure-common~=1.1', ], extras_require={