Azure Schema Registry Apache Avro client library for .NET - Version 1.0.0-beta.1

Azure Schema Registry is a schema repository service hosted by Azure Event Hubs, providing schema storage, versioning, and management. This package provides an Avro serializer capable of serializing and deserializing payloads containing Schema Registry schema identifiers and Avro-encoded data.

Getting started

Install the package

Install the Azure Schema Registry Apache Avro library for .NET with NuGet:

dotnet add package Microsoft.Azure.Data.SchemaRegistry.ApacheAvro --version 1.0.0-beta.1


If you need to create an Event Hubs namespace, you can use the Azure Portal or Azure PowerShell.

You can use Azure PowerShell to create the Event Hubs namespace with the following command:

New-AzEventHubNamespace -ResourceGroupName myResourceGroup -NamespaceName namespace_name -Location eastus

Authenticate the client

In order to interact with the Azure Schema Registry service, you'll need to create an instance of the Schema Registry Client class. To create this client, you'll need Azure resource credentials and the Event Hubs namespace hostname.

Get credentials

To acquire authenicated credentials and start interacting with Azure resources, please see the quickstart guide here.

Get Event Hubs namespace hostname

The simpliest way is to use the Azure portal and navigate to your Event Hubs namespace. From the Overview tab, you'll see Host name. Copy the value from this field.

Create SchemaRegistryClient

Once you have the Azure resource credentials and the Event Hubs namespace hostname, you can create the SchemaRegistryClient. You'll also need the Azure.Identity package to create the credential.

string endpoint = "<event_hubs_namespace_hostname>";
var credentials = new ClientSecretCredential(
var client = new SchemaRegistryClient(endpoint, credentials);

Key concepts


This library provides a serializer, SchemaRegistryAvroObjectSerializer, that implements the ObjectSerializer abstract class. This allows a developer to use this serializer in any .NET Azure SDKs that utilize ObjectSerializer. The SchemaRegistryAvroObjectSerializer utilitizes a SchemaRegistryClient to construct messages using a wire format containing schema information such as a schema ID.

This serializer requires the Apache Avro library. The payload types accepted by this serializer include GenericRecord and ISpecificRecord.

Wire Format

The serializer in this library creates messages in a wire format. The format is the following:

  • Bytes [0-3] – record format indicator – currently is \x00\x00\x00\x00
  • Bytes [4-35] – UTF-8 GUID, identifying the schema in a Schema Registry instance
  • Bytes [36-end] – serialized payload bytes


The following shows examples of what is available through the SchemaRegistryAvroObjectSerializer. There are both sync and async methods available for these operations. These examples use a generated Apache Avro class Employee.cs created using this schema:

   "type" : "record",
    "namespace" : "TestSchema",
    "name" : "Employee",
    "fields" : [
        { "name" : "Name" , "type" : "string" },
        { "name" : "Age", "type" : "int" }

Details on generating a class using the Apache Avro library can be found in the Avro C# Documentation.


Register a schema to be stored in the Azure Schema Registry.

var employee = new Employee { Age = 42, Name = "John Doe" };
string groupName = "<schema_group_name>";

using var memoryStream = new MemoryStream();
var serializer = new SchemaRegistryAvroObjectSerializer(client, groupName, new SchemaRegistryAvroObjectSerializerOptions { AutoRegisterSchemas = true });
serializer.Serialize(memoryStream, employee, typeof(Employee), CancellationToken.None);


Retrieve a previously registered schema ID from the Azure Schema Registry.

string groupName = "<schema_group_name>";

var serializer = new SchemaRegistryAvroObjectSerializer(client, groupName, new SchemaRegistryAvroObjectSerializerOptions { AutoRegisterSchemas = true });
memoryStream.Position = 0;
Employee employee = (Employee)serializer.Deserialize(memoryStream, typeof(Employee), CancellationToken.None);


Information on troubleshooting steps will be provided as potential issues are discovered.

Next steps

See Azure Schema Registry for additional information.


This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact with any additional questions or comments.