Registry / azure / azure-schemaregistry-avroencoder

azure-schemaregistry-avroencoder

JSON →
library1.0.0pypypi✓ verified 84d ago

Microsoft Azure Schema Registry Avro Encoder client library for Python (v1.0.0) enables encoding/decoding Avro data with schema stored in Azure Schema Registry. It is built on Apache Avro (<1.12) and requires Python >=3.7. Release cadence is monthly.

pip install azure-schemaregistry-avroencoder
INSTALL
IMPORT
SIG · AZURE-SCHEMAREGIST
A
azure-schemaregistry-avroencoder
azurepythonv1.0.0
Install
2.6s avg
Import
426ms
Disk
23MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.448s · 25MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.6s · import 0.404s · 26MB
23MB installed
● package 23MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AvroEncoder
from azure.schemaregistry.encoder.avroencoder import AvroEncoder
from azure.schemaregistry.avroencoder import AvroEncoder
Correct import includes 'encoder' subpackage

Encode and decode Avro data with schema registry.

import os from azure.schemaregistry import SchemaRegistryClient from azure.schemaregistry.encoder.avroencoder import AvroEncoder from azure.identity import DefaultAzureCredential credential = DefaultAzureCredential() schema_registry_client = SchemaRegistryClient( fully_qualified_namespace=os.environ.get('SCHEMA_REGISTRY_FQDN', 'example.servicebus.windows.net'), credential=credential ) encoder = AvroEncoder(client=schema_registry_client, group_name=os.environ.get('GROUP_NAME', 'my-group')) # Encode data = {"name": "Alice", "age": 30} schema = { "type": "record", "name": "User", "fields": [ {"name": "name", "type": "string"}, {"name": "age", "type": "int"} ] } encoded = encoder.encode(data, schema=schema) print(f"Encoded bytes: {encoded}") # Decode decoded = encoder.decode(encoded) print(f"Decoded data: {decoded}")
Debug
Known issues
breakingAvro library version: This library requires avro (Apache Avro) version >=1.10.0, <1.12.0. Using avro>=1.12 will cause import errors.
fix
Pin avro to >=1.10.0,<1.12.0 in your requirements.
affects: 1.0.0
gotchaAvroEncoder is not thread-safe for encode/decode operations due to internal schema cache. Create a new instance per thread or use locks.
fix
Create a new AvroEncoder per thread or synchronize access.
affects: >=1.0.0
deprecatedPython 3.6 support ended. The library requires Python >=3.7 for this version.
fix
Upgrade Python to >=3.7.
affects: 1.0.0
Errors
Common errors & fixes
ImportError: cannot import name 'AvroEncoder' from 'azure.schemaregistry.avroencoder'
Incorrect import path missing 'encoder' subpackage.
fix
Use: from azure.schemaregistry.encoder.avroencoder import AvroEncoder
AvroException: 'int' object has no attribute 'encode'
Passing a single value instead of a dict with schema fields.
fix
Ensure data is a dictionary matching the Avro schema record.
Upgrade
Version history
1.0.0latest on PyPI · released May 10, 2022
Audit
Dependencies
azure-schemaregistryrequiredRequired for schema registry client
avrorequiredAvro library for serialization
Agent activity
26 hits · last 30 days
node
24
OpenAI (training)
1
Resources
azure-schemaregistry-avroencoder — pip install azure-schemaregistry-avroencoder · libregistry