From c3c462557d00e1478507c99e0c0b4c6c954155db Mon Sep 17 00:00:00 2001 From: Yunhao Ling Date: Fri, 18 Sep 2020 15:57:47 -0700 Subject: [PATCH 1/5] add sample for EH integration --- .../samples/README.md | 6 ++ .../samples/eventhub_receive_integration.py | 83 +++++++++++++++++++ .../samples/eventhub_send_integration.py | 78 +++++++++++++++++ 3 files changed, 167 insertions(+) create mode 100644 sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_receive_integration.py create mode 100644 sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_send_integration.py diff --git a/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/README.md b/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/README.md index 7dfb44bc4e3d..bfd4caada5a0 100644 --- a/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/README.md +++ b/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/README.md @@ -17,6 +17,10 @@ Several Schema Registry Avro Serializer Python SDK samples are available to you * [avro_serializer.py][avro_serializer_sample] - Examples for common Schema Registry Avro Serializer tasks: * Serialize data according to the given schema * Deserialize data +* [eventhub_send_integration.py][eventhub_send_integration_sample] - Examples for integration with EventHub in sending tasks: + * Serialize data with the given schema and send `EventData` to Event Hubs. +* [eventhub_receive_integration.py][eventhub_receive_integration_sample] - Examples for integration with EventHub in receiving tasks: + * Receive `EventData` from Event Hubs and deserialize the received bytes. ## Prerequisites - Python 2.7, 3.5 or later. @@ -47,4 +51,6 @@ what you can do with the Azure Schema Registry Avro Serializer library. [avro_serializer_sample]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/avro_serializer.py +[eventhub_send_integration_sample]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_send_integration.py +[eventhub_receive_integration_sample]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_receive_integration.py [api_reference]: https://azuresdkdocs.blob.core.windows.net/$web/python/azure-schemaregistry-avroserializer/latest/index.html diff --git a/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_receive_integration.py b/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_receive_integration.py new file mode 100644 index 000000000000..c2707a6547d0 --- /dev/null +++ b/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_receive_integration.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python + +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +""" +Examples to show receiving events from EventHub with SchemaRegistryAvroSerializer integrated for data deserialization. +""" + +# pylint: disable=C0111 +import os +from azure.eventhub import EventHubConsumerClient +from azure.identity import ClientSecretCredential +from azure.schemaregistry.serializer.avro_serializer import SchemaRegistryAvroSerializer + +EVENTHUB_CONNECTION_STR = os.environ['EVENT_HUB_CONN_STR'] +EVENTHUB_NAME = os.environ['EVENT_HUB_NAME'] + +SCHEMA_REGISTRY_TENANT_ID = os.environ['SCHEMA_REGISTRY_AZURE_TENANT_ID'] +SCHEMA_REGISTRY_CLIENT_ID = os.environ['SCHEMA_REGISTRY_AZURE_CLIENT_ID'] +SCHEMA_REGISTRY_CLIENT_SECRET = os.environ['SCHEMA_REGISTRY_AZURE_CLIENT_SECRET'] +SCHEMA_REGISTRY_ENDPOINT = os.environ['SCHEMA_REGISTRY_ENDPOINT'] +SCHEMA_GROUP = os.environ['SCHEMA_REGISTRY_GROUP'] + +SCHEMA_STRING = """ +{"namespace": "example.avro", + "type": "record", + "name": "User", + "fields": [ + {"name": "name", "type": "string"}, + {"name": "favorite_number", "type": ["int", "null"]}, + {"name": "favorite_color", "type": ["string", "null"]} + ] +}""" + + +def on_event(partition_context, event): + print("Received event from partition: {}.".format(partition_context.partition_id)) + + bytes_payload = b"".join(b for b in event.body) + print('The received bytes of the EventData is {}.'.format(bytes_payload)) + + # Use the deserialize method to convert bytes to dict object. + # The deserialize method would extract the schema id from the payload, and automatically retrieve the Avro Schema + # from the Schema Registry Service. The schema would be cached locally for future usage. + deserialized_data = avro_serializer.deserialize(bytes_payload) + print('The dict data after deserialization is {}'.format(deserialized_data)) + + +# create an EventHubConsumerClient instance +eventhub_consumer = EventHubConsumerClient.from_connection_string( + conn_str=EVENTHUB_CONNECTION_STR, + consumer_group='$Default', + eventhub_name=EVENTHUB_NAME, +) + + +# create the credential object which is used for Schema Registry Service Authentication +schema_registry_token_credential = ClientSecretCredential( + tenant_id=SCHEMA_REGISTRY_TENANT_ID, + client_id=SCHEMA_REGISTRY_CLIENT_ID, + client_secret=SCHEMA_REGISTRY_CLIENT_SECRET +) + + +# create a SchemaRegistryAvroSerializer instance +avro_serializer = SchemaRegistryAvroSerializer( + endpoint=SCHEMA_REGISTRY_ENDPOINT, + credential=schema_registry_token_credential, + schema_group=SCHEMA_GROUP +) + + +try: + with eventhub_consumer, avro_serializer: + eventhub_consumer.receive( + on_event=on_event, + starting_position="-1", # "-1" is from the beginning of the partition. + ) +except KeyboardInterrupt: + print('Stopped receiving.') diff --git a/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_send_integration.py b/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_send_integration.py new file mode 100644 index 000000000000..42a13146683f --- /dev/null +++ b/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_send_integration.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python + +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +""" +Examples to show sending event to EventHub with SchemaRegistryAvroSerializer integrated for data serialization. +""" + +# pylint: disable=C0111 + +import os +from azure.eventhub import EventHubProducerClient, EventData +from azure.identity import ClientSecretCredential +from azure.schemaregistry.serializer.avro_serializer import SchemaRegistryAvroSerializer + +EVENTHUB_CONNECTION_STR = os.environ['EVENT_HUB_CONN_STR'] +EVENTHUB_NAME = os.environ['EVENT_HUB_NAME'] + +SCHEMA_REGISTRY_TENANT_ID = os.environ['SCHEMA_REGISTRY_AZURE_TENANT_ID'] +SCHEMA_REGISTRY_CLIENT_ID = os.environ['SCHEMA_REGISTRY_AZURE_CLIENT_ID'] +SCHEMA_REGISTRY_CLIENT_SECRET = os.environ['SCHEMA_REGISTRY_AZURE_CLIENT_SECRET'] +SCHEMA_REGISTRY_ENDPOINT = os.environ['SCHEMA_REGISTRY_ENDPOINT'] +SCHEMA_GROUP = os.environ['SCHEMA_REGISTRY_GROUP'] + +SCHEMA_STRING = """ +{"namespace": "example.avro", + "type": "record", + "name": "User", + "fields": [ + {"name": "name", "type": "string"}, + {"name": "favorite_number", "type": ["int", "null"]}, + {"name": "favorite_color", "type": ["string", "null"]} + ] +}""" + + +def send_event_data_batch(producer, serializer): + event_data_batch = producer.create_batch() + + dict_data = {"name": "Bob", "favorite_number": 7, "favorite_color": "red"} + # Use the serialize method to convert dict object to bytes with the given avro schema. + # The serialize method would automatically register the schema into the Schema Registry Service and + # schema would be cached locally for future usage. + payload_bytes = serializer.serialize(data=dict_data, schema=SCHEMA_STRING) + print('The bytes of serialized dict data is {}.'.format(payload_bytes)) + + event_data = EventData(body=payload_bytes) # pass the bytes data to the body of an EventData + event_data_batch.add(event_data) + producer.send_batch(event_data_batch) + print('Send is done.') + + +# create an EventHubProducerClient instance +eventhub_producer = EventHubProducerClient.from_connection_string( + conn_str=EVENTHUB_CONNECTION_STR, + eventhub_name=EVENTHUB_NAME +) + +# create the credential object which is used for Schema Registry Service Authentication +schema_registry_token_credential = ClientSecretCredential( + tenant_id=SCHEMA_REGISTRY_TENANT_ID, + client_id=SCHEMA_REGISTRY_CLIENT_ID, + client_secret=SCHEMA_REGISTRY_CLIENT_SECRET +) + +# create a SchemaRegistryAvroSerializer instance +avro_serializer = SchemaRegistryAvroSerializer( + endpoint=SCHEMA_REGISTRY_ENDPOINT, + credential=schema_registry_token_credential, + schema_group=SCHEMA_GROUP +) + + +with eventhub_producer, avro_serializer: + send_event_data_batch(eventhub_producer, avro_serializer) From 5b28116628d9e965e8603781be6141640b6b23ce Mon Sep 17 00:00:00 2001 From: Yunhao Ling Date: Fri, 18 Sep 2020 16:25:58 -0700 Subject: [PATCH 2/5] add samples to readme and tweak the code --- .../README.md | 74 +++++++++++++++++++ .../samples/eventhub_receive_integration.py | 33 ++------- .../samples/eventhub_send_integration.py | 20 ++--- 3 files changed, 88 insertions(+), 39 deletions(-) diff --git a/sdk/schemaregistry/azure-schemaregistry-avroserializer/README.md b/sdk/schemaregistry/azure-schemaregistry-avroserializer/README.md index 0973eb1ad23d..1ae63edd7641 100644 --- a/sdk/schemaregistry/azure-schemaregistry-avroserializer/README.md +++ b/sdk/schemaregistry/azure-schemaregistry-avroserializer/README.md @@ -76,6 +76,8 @@ The following sections provide several code snippets covering some of the most c - [Serialization](#serialization) - [Deserialization](#deserialization) +- [Event Hubs Sending Integration](#event-hubs-sending-integration) +- [Event Hubs Receiving Integration](#event-hubs-receiving-integration) ### Serialization @@ -128,6 +130,78 @@ with serializer: decoded_data = serializer.deserialize(encoded_bytes) ``` +### Event Hubs Sending Integration +```python +import os +from azure.eventhub import EventHubProducerClient, EventData +from azure.schemaregistry import SchemaRegistryClient +from azure.schemaregistry.serializer.avroserializer import SchemaRegistryAvroSerializer +from azure.identity import DefaultAzureCredential + +token_credential = DefaultAzureCredential() +endpoint = os.environ['SCHEMA_REGISTRY_ENDPOINT'] +schema_group = "" +eventhub_connection_str = os.environ['EVENT_HUB_CONN_STR'] +eventhub_name = os.environ['EVENT_HUB_NAME'] + +schema_string = """ +{"namespace": "example.avro", + "type": "record", + "name": "User", + "fields": [ + {"name": "name", "type": "string"}, + {"name": "favorite_number", "type": ["int", "null"]}, + {"name": "favorite_color", "type": ["string", "null"]} + ] +}""" + +schema_registry_client = SchemaRegistryClient(endpoint, token_credential) +avro_serializer = SchemaRegistryAvroSerializer(schema_registry_client, schema_group) + +eventhub_producer = EventHubProducerClient.from_connection_string( + conn_str=eventhub_connection_str, + eventhub_name=eventhub_name +) + +with eventhub_producer, avro_serializer: + event_data_batch = eventhub_producer.create_batch() + dict_data = {"name": "Bob", "favorite_number": 7, "favorite_color": "red"} + payload_bytes = avro_serializer.serialize(data=dict_data, schema=schema_string) + event_data_batch.add(EventData(body=payload_bytes)) + eventhub_producer.send_batch(event_data_batch) +``` + +### Event Hubs Receiving Integration +```python +import os +from azure.eventhub import EventHubConsumerClient +from azure.schemaregistry import SchemaRegistryClient +from azure.schemaregistry.serializer.avroserializer import SchemaRegistryAvroSerializer +from azure.identity import DefaultAzureCredential + +token_credential = DefaultAzureCredential() +endpoint = os.environ['SCHEMA_REGISTRY_ENDPOINT'] +schema_group = "" +eventhub_connection_str = os.environ['EVENT_HUB_CONN_STR'] +eventhub_name = os.environ['EVENT_HUB_NAME'] + +schema_registry_client = SchemaRegistryClient(endpoint, token_credential) +avro_serializer = SchemaRegistryAvroSerializer(schema_registry_client, schema_group) + +eventhub_consumer = EventHubConsumerClient.from_connection_string( + conn_str=eventhub_connection_str, + consumer_group='$Default', + eventhub_name=eventhub_name, +) + +def on_event(partition_context, event): + bytes_payload = b"".join(b for b in event.body) + deserialized_data = avro_serializer.deserialize(bytes_payload) + +with eventhub_consumer, avro_serializer: + eventhub_consumer.receive(on_event=on_event, starting_position="-1") +``` + ## Troubleshooting ### General diff --git a/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_receive_integration.py b/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_receive_integration.py index c2707a6547d0..95919dc5756f 100644 --- a/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_receive_integration.py +++ b/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_receive_integration.py @@ -12,29 +12,16 @@ # pylint: disable=C0111 import os from azure.eventhub import EventHubConsumerClient -from azure.identity import ClientSecretCredential -from azure.schemaregistry.serializer.avro_serializer import SchemaRegistryAvroSerializer +from azure.identity import DefaultAzureCredential +from azure.schemaregistry import SchemaRegistryClient +from azure.schemaregistry.serializer.avroserializer import SchemaRegistryAvroSerializer EVENTHUB_CONNECTION_STR = os.environ['EVENT_HUB_CONN_STR'] EVENTHUB_NAME = os.environ['EVENT_HUB_NAME'] -SCHEMA_REGISTRY_TENANT_ID = os.environ['SCHEMA_REGISTRY_AZURE_TENANT_ID'] -SCHEMA_REGISTRY_CLIENT_ID = os.environ['SCHEMA_REGISTRY_AZURE_CLIENT_ID'] -SCHEMA_REGISTRY_CLIENT_SECRET = os.environ['SCHEMA_REGISTRY_AZURE_CLIENT_SECRET'] SCHEMA_REGISTRY_ENDPOINT = os.environ['SCHEMA_REGISTRY_ENDPOINT'] SCHEMA_GROUP = os.environ['SCHEMA_REGISTRY_GROUP'] -SCHEMA_STRING = """ -{"namespace": "example.avro", - "type": "record", - "name": "User", - "fields": [ - {"name": "name", "type": "string"}, - {"name": "favorite_number", "type": ["int", "null"]}, - {"name": "favorite_color", "type": ["string", "null"]} - ] -}""" - def on_event(partition_context, event): print("Received event from partition: {}.".format(partition_context.partition_id)) @@ -57,18 +44,12 @@ def on_event(partition_context, event): ) -# create the credential object which is used for Schema Registry Service Authentication -schema_registry_token_credential = ClientSecretCredential( - tenant_id=SCHEMA_REGISTRY_TENANT_ID, - client_id=SCHEMA_REGISTRY_CLIENT_ID, - client_secret=SCHEMA_REGISTRY_CLIENT_SECRET -) - - # create a SchemaRegistryAvroSerializer instance avro_serializer = SchemaRegistryAvroSerializer( - endpoint=SCHEMA_REGISTRY_ENDPOINT, - credential=schema_registry_token_credential, + schema_registry=SchemaRegistryClient( + endpoint=SCHEMA_REGISTRY_ENDPOINT, + credential=DefaultAzureCredential() + ), schema_group=SCHEMA_GROUP ) diff --git a/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_send_integration.py b/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_send_integration.py index 42a13146683f..3509eeb2904e 100644 --- a/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_send_integration.py +++ b/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_send_integration.py @@ -13,15 +13,13 @@ import os from azure.eventhub import EventHubProducerClient, EventData -from azure.identity import ClientSecretCredential -from azure.schemaregistry.serializer.avro_serializer import SchemaRegistryAvroSerializer +from azure.identity import DefaultAzureCredential +from azure.schemaregistry import SchemaRegistryClient +from azure.schemaregistry.serializer.avroserializer import SchemaRegistryAvroSerializer EVENTHUB_CONNECTION_STR = os.environ['EVENT_HUB_CONN_STR'] EVENTHUB_NAME = os.environ['EVENT_HUB_NAME'] -SCHEMA_REGISTRY_TENANT_ID = os.environ['SCHEMA_REGISTRY_AZURE_TENANT_ID'] -SCHEMA_REGISTRY_CLIENT_ID = os.environ['SCHEMA_REGISTRY_AZURE_CLIENT_ID'] -SCHEMA_REGISTRY_CLIENT_SECRET = os.environ['SCHEMA_REGISTRY_AZURE_CLIENT_SECRET'] SCHEMA_REGISTRY_ENDPOINT = os.environ['SCHEMA_REGISTRY_ENDPOINT'] SCHEMA_GROUP = os.environ['SCHEMA_REGISTRY_GROUP'] @@ -59,17 +57,13 @@ def send_event_data_batch(producer, serializer): eventhub_name=EVENTHUB_NAME ) -# create the credential object which is used for Schema Registry Service Authentication -schema_registry_token_credential = ClientSecretCredential( - tenant_id=SCHEMA_REGISTRY_TENANT_ID, - client_id=SCHEMA_REGISTRY_CLIENT_ID, - client_secret=SCHEMA_REGISTRY_CLIENT_SECRET -) # create a SchemaRegistryAvroSerializer instance avro_serializer = SchemaRegistryAvroSerializer( - endpoint=SCHEMA_REGISTRY_ENDPOINT, - credential=schema_registry_token_credential, + schema_registry=SchemaRegistryClient( + endpoint=SCHEMA_REGISTRY_ENDPOINT, + credential=DefaultAzureCredential() + ), schema_group=SCHEMA_GROUP ) From 594c2641e9f99f4b8c86fc6fa35cb74205447e9d Mon Sep 17 00:00:00 2001 From: Yunhao Ling Date: Mon, 21 Sep 2020 13:56:23 -0700 Subject: [PATCH 3/5] add descriptions --- .../README.md | 12 ++++++++++++ .../azure-schemaregistry/README.md | 18 +++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/sdk/schemaregistry/azure-schemaregistry-avroserializer/README.md b/sdk/schemaregistry/azure-schemaregistry-avroserializer/README.md index 1ae63edd7641..e0b4d15ff0fe 100644 --- a/sdk/schemaregistry/azure-schemaregistry-avroserializer/README.md +++ b/sdk/schemaregistry/azure-schemaregistry-avroserializer/README.md @@ -81,6 +81,9 @@ The following sections provide several code snippets covering some of the most c ### Serialization +Use `SchemaRegistryAvroSerializer.serialize` method to serialize dict data with the given avro schema. +The method would automatically register the schema to the Schema Registry Service and keep the schema cached for future serialization usage. + ```python import os from azure.schemaregistry import SchemaRegistryClient @@ -112,6 +115,9 @@ with serializer: ### Deserialization +Use `SchemaRegistryAvroSerializer.deserialize` method to deserialize raw bytes into dict data. +The method would automatically retrieve the schema from the Schema Registry Service and keep the schema cached for future deserialization usage. + ```python import os from azure.schemaregistry import SchemaRegistryClient @@ -131,6 +137,9 @@ with serializer: ``` ### Event Hubs Sending Integration + +Integration with Event Hubs to send serialized avro dict data as the body of EventData. + ```python import os from azure.eventhub import EventHubProducerClient, EventData @@ -172,6 +181,9 @@ with eventhub_producer, avro_serializer: ``` ### Event Hubs Receiving Integration + +Integration with Event Hubs to receive `EventData` and deserialized raw bytes into avro dict data. + ```python import os from azure.eventhub import EventHubConsumerClient diff --git a/sdk/schemaregistry/azure-schemaregistry/README.md b/sdk/schemaregistry/azure-schemaregistry/README.md index 1f632899cada..03cbbdbd3188 100644 --- a/sdk/schemaregistry/azure-schemaregistry/README.md +++ b/sdk/schemaregistry/azure-schemaregistry/README.md @@ -52,6 +52,8 @@ The following sections provide several code snippets covering some of the most c ### Register a schema +Use `SchemaRegistryClient.register_schema` method to register a schema. + ```python import os @@ -83,6 +85,8 @@ with schema_registry_client: ### Get the schema by id +Get the schema content and its properties by schema id. + ```python import os @@ -101,6 +105,8 @@ with schema_registry_client: ### Get the id of a schema +Get the schema id of a schema by schema content and its properties. + ```python import os @@ -171,6 +177,14 @@ schema_registry_client.get_schema(schema_id, logging_enable=True) ## Next steps +### Serializer + +**Azure Schema Registry Avro Serializer** + +We provide [azure-schemaregistry-avroserializer][schemaregistry_avroserializer_pypi] library as serializer +implementation to serialize/deserialize avro data integrated with `azure-schemaregistry` for automatic schema registration and retrieval. +Please refer to the [repository][schemaregistry_avroserializer_repo] for further information. + ### More sample code Please take a look at the [samples][sr_samples] directory for detailed examples of how to use this library to register and retrieve schema to/from Schema Registry. @@ -200,4 +214,6 @@ contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additio [api_reference]: https://azuresdkdocs.blob.core.windows.net/$web/python/azure-schemaregistry/latest/index.html [source_code]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/schemaregistry/azure-schemaregistry [change_log]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md -[schemaregistry_service]: https://aka.ms/schemaregistry \ No newline at end of file +[schemaregistry_service]: https://aka.ms/schemaregistry +[schemaregistry_avroserializer_repo]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/schemaregistry/azure-schemaregistry-avroserializer +[schemaregistry_avroserializer_pypi]: https://pypi.org/project/azure-schemaregistry-avroserializer/ From abbfe19864746456734c83584d2b8499c9b6547e Mon Sep 17 00:00:00 2001 From: Yunhao Ling Date: Mon, 21 Sep 2020 14:22:29 -0700 Subject: [PATCH 4/5] mention SR and serializer in EH --- sdk/eventhub/azure-eventhub/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sdk/eventhub/azure-eventhub/README.md b/sdk/eventhub/azure-eventhub/README.md index 12c644e32658..87d1f4037a32 100644 --- a/sdk/eventhub/azure-eventhub/README.md +++ b/sdk/eventhub/azure-eventhub/README.md @@ -414,6 +414,11 @@ Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-pytho Reference documentation is available [here](https://azuresdkdocs.blob.core.windows.net/$web/python/azure-eventhub/latest/azure.eventhub.html). +### Schema Registry and Serializer + +The EventHubs SDK integrates nicely with the [Schema Registry][schemaregistry_service] service and [Avro][avro]. +For more information, please refer to [Schema Registry SDK][schemaregistry_repo] and [Schema Registry Avro Serializer SDK][schemaregistry_avroserializer_repo]. + ### Provide Feedback If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project. @@ -429,4 +434,9 @@ PR appropriately (e.g., label, comment). Simply follow the instructions provided This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. +[avro]: http://avro.apache.org/ +[schemaregistry_service]: https://aka.ms/schemaregistry +[schemaregistry_repo]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/schemaregistry/azure-schemaregistry +[schemaregistry_avroserializer_repo]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/schemaregistry/azure-schemaregistry-avroserializer + ![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python/sdk/eventhub/azure-eventhub/README.png) From 0b714c5bd6a3e05a7984e0080b7bbdff79b8a5f9 Mon Sep 17 00:00:00 2001 From: Yunhao Ling Date: Mon, 21 Sep 2020 15:16:00 -0700 Subject: [PATCH 5/5] small tweak --- sdk/eventhub/azure-eventhub/README.md | 2 +- .../azure-schemaregistry-avroserializer/README.md | 7 ++++--- sdk/schemaregistry/azure-schemaregistry/README.md | 14 +++++++------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/sdk/eventhub/azure-eventhub/README.md b/sdk/eventhub/azure-eventhub/README.md index 87d1f4037a32..22f7cab7c95c 100644 --- a/sdk/eventhub/azure-eventhub/README.md +++ b/sdk/eventhub/azure-eventhub/README.md @@ -414,7 +414,7 @@ Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-pytho Reference documentation is available [here](https://azuresdkdocs.blob.core.windows.net/$web/python/azure-eventhub/latest/azure.eventhub.html). -### Schema Registry and Serializer +### Schema Registry and Avro Serializer The EventHubs SDK integrates nicely with the [Schema Registry][schemaregistry_service] service and [Avro][avro]. For more information, please refer to [Schema Registry SDK][schemaregistry_repo] and [Schema Registry Avro Serializer SDK][schemaregistry_avroserializer_repo]. diff --git a/sdk/schemaregistry/azure-schemaregistry-avroserializer/README.md b/sdk/schemaregistry/azure-schemaregistry-avroserializer/README.md index e0b4d15ff0fe..02e885a6b405 100644 --- a/sdk/schemaregistry/azure-schemaregistry-avroserializer/README.md +++ b/sdk/schemaregistry/azure-schemaregistry-avroserializer/README.md @@ -138,7 +138,7 @@ with serializer: ### Event Hubs Sending Integration -Integration with Event Hubs to send serialized avro dict data as the body of EventData. +Integration with [Event Hubs][eventhubs_repo] to send serialized avro dict data as the body of EventData. ```python import os @@ -182,7 +182,7 @@ with eventhub_producer, avro_serializer: ### Event Hubs Receiving Integration -Integration with Event Hubs to receive `EventData` and deserialized raw bytes into avro dict data. +Integration with [Event Hubs][eventhubs_repo] to receive `EventData` and deserialized raw bytes into avro dict data. ```python import os @@ -287,4 +287,5 @@ contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additio [source_code]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/schemaregistry/azure-schemaregistry-avroserializer [change_log]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/schemaregistry/azure-schemaregistry-avroserializer/CHANGELOG.md [schemaregistry_client]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/schemaregistry/azure-schemaregistry -[schemaregistry_service]: https://aka.ms/schemaregistry \ No newline at end of file +[schemaregistry_service]: https://aka.ms/schemaregistry +[eventhubs_repo]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/eventhub/azure-eventhub \ No newline at end of file diff --git a/sdk/schemaregistry/azure-schemaregistry/README.md b/sdk/schemaregistry/azure-schemaregistry/README.md index 03cbbdbd3188..c62370086f1b 100644 --- a/sdk/schemaregistry/azure-schemaregistry/README.md +++ b/sdk/schemaregistry/azure-schemaregistry/README.md @@ -177,17 +177,16 @@ schema_registry_client.get_schema(schema_id, logging_enable=True) ## Next steps -### Serializer +### More sample code + +Please take a look at the [samples][sr_samples] directory for detailed examples of how to use this library to register and retrieve schema to/from Schema Registry. -**Azure Schema Registry Avro Serializer** +### Event Hubs and Avro Serializer We provide [azure-schemaregistry-avroserializer][schemaregistry_avroserializer_pypi] library as serializer implementation to serialize/deserialize avro data integrated with `azure-schemaregistry` for automatic schema registration and retrieval. -Please refer to the [repository][schemaregistry_avroserializer_repo] for further information. - -### More sample code - -Please take a look at the [samples][sr_samples] directory for detailed examples of how to use this library to register and retrieve schema to/from Schema Registry. +It integrates nicely with the [EventHubs SDK][eventhubs_repo]. +For more information and sample codes, please refer to the [Azure Schema Registry Avro Serializer SDK][schemaregistry_avroserializer_repo]. ## Contributing @@ -217,3 +216,4 @@ contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additio [schemaregistry_service]: https://aka.ms/schemaregistry [schemaregistry_avroserializer_repo]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/schemaregistry/azure-schemaregistry-avroserializer [schemaregistry_avroserializer_pypi]: https://pypi.org/project/azure-schemaregistry-avroserializer/ +[eventhubs_repo]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/eventhub/azure-eventhub \ No newline at end of file