Azure Schema Registry Avro Encoder library for Python Samples
These are code samples that show common scenario operations with the Schema Registry Avro Encoder library.
Several Schema Registry Avro Encoder Python SDK samples are available to you in the SDK's GitHub repository. These samples provide example code for additional scenarios commonly encountered while working with Schema Registry Avro Encoder:
- encode_and_decode_event_data_message.py (async version) - Examples for common Schema Registry Avro Encoder tasks:
- Encode content according to the given schema and create EventData object
- Decode content given an EventData object with encoded content and corresponding content type
- eventhub_send_integration.py (async version) - Examples for integration with EventHub in sending tasks:
- Encode content with the given schema and send
EventData
to Event Hubs.
- Encode content with the given schema and send
- eventhub_receive_integration.py (async version) - Examples for integration with EventHub in receiving tasks:
- Receive
EventData
from Event Hubs and decode the received bytes.
- Receive
Prerequisites
- Python 3.7 or later.
- Microsoft Azure Subscription: To use Azure services, including Azure Schema Registry, you'll need a subscription. If you do not have an existing Azure account, you may sign up for a free trial or use your MSDN subscriber benefits when you create an account.
Setup
- Install the Azure Schema Registry Avro Encoder client library and Azure Identity client library for Python with pip:
pip install azure-schemaregistry-avroencoder azure-identity
Additionally, if using with azure.eventhub.EventData
, install azure-eventhub>=5.9.0
:
pip install azure-eventhub>=5.9.0
- Clone or download this sample repository
- Open the sample folder in Visual Studio Code or your IDE of choice.
Running the samples
- Open a terminal window and
cd
to the directory that the samples are saved in. - Set the environment variables specified in the sample file you wish to run.
- Follow the usage described in the file, e.g.
python encode_and_decode_event_data_message.py
Next steps
Check out the API reference documentation to learn more about what you can do with the Azure Schema Registry Avro Encoder library.