azure.schemaregistry.serializer.avroserializer package

class azure.schemaregistry.serializer.avroserializer.SchemaRegistryAvroSerializer(schema_registry: SchemaRegistryClient, schema_group: str, **kwargs: Any)[source]

SchemaRegistryAvroSerializer provides the ability to serialize and deserialize data according to the given avro schema. It would automatically register, get and cache the schema.

  • schema_registry (SchemaRegistryClient) – The schema registry client which is used to register schema and retrieve schema from the service.

  • schema_group (str) – Schema group under which schema should be registered.

Keyword Arguments

codec (str) – The writer codec. If None, let the avro library decides.


This method is to close the sockets opened by the client. It need not be used when using with a context manager.

deserialize(data: bytes, **kwargs: Any) → Dict[str, Any][source]

Decode bytes data.


data (bytes) – The bytes data needs to be decoded.

Return type

Dict[str, Any]

serialize(data: Dict[str, Any], schema: Union[str, bytes], **kwargs: Any)bytes[source]

Encode dict data with the given schema. The returns bytes are consisted of: The first 4 bytes denoting record format identifier. The following 32 bytes denoting schema id returned by schema registry service. The remaining bytes are the real data payload.

  • data – The dict data to be encoded.

  • schema (Union[str, bytes]) – The schema used to encode the data.