{"id":23334,"library":"azure-schemaregistry-avroencoder","title":"Azure Schema Registry Avro Encoder Client Library for Python","description":"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.","status":"active","version":"1.0.0","language":"python","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python","tags":["azure","schema-registry","avro","encoder"],"install":[{"cmd":"pip install azure-schemaregistry-avroencoder","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for schema registry client","package":"azure-schemaregistry","optional":false},{"reason":"Avro library for serialization","package":"avro","optional":false}],"imports":[{"note":"Correct import includes 'encoder' subpackage","wrong":"from azure.schemaregistry.avroencoder import AvroEncoder","symbol":"AvroEncoder","correct":"from azure.schemaregistry.encoder.avroencoder import AvroEncoder"}],"quickstart":{"code":"import os\nfrom azure.schemaregistry import SchemaRegistryClient\nfrom azure.schemaregistry.encoder.avroencoder import AvroEncoder\nfrom azure.identity import DefaultAzureCredential\n\ncredential = DefaultAzureCredential()\nschema_registry_client = SchemaRegistryClient(\n    fully_qualified_namespace=os.environ.get('SCHEMA_REGISTRY_FQDN', 'example.servicebus.windows.net'),\n    credential=credential\n)\nencoder = AvroEncoder(client=schema_registry_client, group_name=os.environ.get('GROUP_NAME', 'my-group'))\n\n# Encode\ndata = {\"name\": \"Alice\", \"age\": 30}\nschema = {\n    \"type\": \"record\",\n    \"name\": \"User\",\n    \"fields\": [\n        {\"name\": \"name\", \"type\": \"string\"},\n        {\"name\": \"age\", \"type\": \"int\"}\n    ]\n}\nencoded = encoder.encode(data, schema=schema)\nprint(f\"Encoded bytes: {encoded}\")\n\n# Decode\ndecoded = encoder.decode(encoded)\nprint(f\"Decoded data: {decoded}\")","lang":"python","description":"Encode and decode Avro data with schema registry."},"warnings":[{"fix":"Pin avro to >=1.10.0,<1.12.0 in your requirements.","message":"Avro library version: This library requires avro (Apache Avro) version >=1.10.0, <1.12.0. Using avro>=1.12 will cause import errors.","severity":"breaking","affected_versions":"1.0.0"},{"fix":"Create a new AvroEncoder per thread or synchronize access.","message":"AvroEncoder is not thread-safe for encode/decode operations due to internal schema cache. Create a new instance per thread or use locks.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade Python to >=3.7.","message":"Python 3.6 support ended. The library requires Python >=3.7 for this version.","severity":"deprecated","affected_versions":"1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use: from azure.schemaregistry.encoder.avroencoder import AvroEncoder","cause":"Incorrect import path missing 'encoder' subpackage.","error":"ImportError: cannot import name 'AvroEncoder' from 'azure.schemaregistry.avroencoder'"},{"fix":"Ensure data is a dictionary matching the Avro schema record.","cause":"Passing a single value instead of a dict with schema fields.","error":"AvroException: 'int' object has no attribute 'encode'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}