azure.schemaregistry.serializer.avroserializer.aio package

class azure.schemaregistry.serializer.avroserializer.aio.AvroSerializer(**kwargs: Any)[source]

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

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

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

  • auto_register_schemas (bool) – When true, register new schemas passed to serialize. Otherwise, and by default, serialization will fail if the schema has not been pre-registered in the registry.

async close()None[source]

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

async deserialize(value: bytes, **kwargs: Any)Dict[str, Any][source]

Decode bytes data.

Data must follow format of associated Avro RecordSchema:


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

Return type

Dict[str, Any]

async serialize(value: Mapping[str, Any], **kwargs: Any)bytes[source]

Encode 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.

Schema must be an Avro RecordSchema:


value (Mapping[str, Any]) – The data to be encoded.

Keyword Arguments

schema (str) – Required. The schema used to encode the data.

Return type