Registry /
azure / azure-schemaregistry-avroencoder
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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.448s · 25MB
glibcpy 3.10–3.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}")
Errors
Common errors & fixes
ImportError: cannot import name 'AvroEncoder' from 'azure.schemaregistry.avroencoder'
Incorrect import path missing 'encoder' subpackage.
fixUse: 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.
fixEnsure 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