Azure Schema Registry client library for .NET - version 1.3.0

Azure Schema Registry is a schema repository service hosted by Azure Event Hubs, providing schema storage, versioning, and management. The registry is leveraged by serializers to reduce payload size while describing payload structure with schema identifiers rather than full schemas.

Getting started

Install the package

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

dotnet add package Azure.Data.SchemaRegistry


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.

// Create a new SchemaRegistry client using the default credential from Azure.Identity using environment variables previously set,
// For more information on Azure.Identity usage, see:
var client = new SchemaRegistryClient(fullyQualifiedNamespace: fullyQualifiedNamespace, credential: new DefaultAzureCredential());

Key concepts


A schema has 6 components:

  • Group Name: The name of the group of schemas in the Schema Registry instance.
  • Schema Name: The name of the schema.
  • Schema ID: The ID assigned by the Schema Registry instance for the schema.
  • Schema Format: The format used for serialization of the schema. For example, Avro.
  • Schema Content: The string representation of the schema.
  • Schema Version: The version assigned to the schema in the Schema Registry instance.

These components play different roles. Some are used as input into the operations and some are outputs. Currently, SchemaProperties only exposes those properties that are potential outputs that are used in SchemaRegistry operations. Those exposed properties are Content and Id.

Thread safety

We guarantee that all client instance methods are thread-safe and independent of each other (guideline). This ensures that the recommendation of reusing client instances is always safe, even across threads.

Additional concepts

Client options | Accessing the response | Long-running operations | Handling failures | Diagnostics | Mocking | Client lifetime


The following shows examples of what is available through the SchemaRegistryClient. There are both sync and async methods available for these client operations.

Register a schema

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

string name = "employeeSample";
SchemaFormat format = SchemaFormat.Avro;
// Example schema's definition
string definition = @"
   ""type"" : ""record"",
    ""namespace"" : ""TestSchema"",
    ""name"" : ""Employee"",
    ""fields"" : [
    { ""name"" : ""Name"" , ""type"" : ""string"" },
    { ""name"" : ""Age"", ""type"" : ""int"" }

Response<SchemaProperties> schemaProperties = client.RegisterSchema(groupName, name, definition, format);

Retrieve a schema ID

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

string name = "employeeSample";
SchemaFormat format = SchemaFormat.Avro;
// Example schema's content
string content = @"
   ""type"" : ""record"",
    ""namespace"" : ""TestSchema"",
    ""name"" : ""Employee"",
    ""fields"" : [
    { ""name"" : ""Name"" , ""type"" : ""string"" },
    { ""name"" : ""Age"", ""type"" : ""int"" }

SchemaProperties schemaProperties = client.GetSchemaProperties(groupName, name, content, format);
string schemaId = schemaProperties.Id;

Retrieve a schema

Retrieve a previously registered schema's content from the Azure Schema Registry with either a schema ID or the group name, schema name, and version.

SchemaRegistrySchema schema = client.GetSchema(schemaId);
string definition = schema.Definition;
SchemaRegistrySchema schema = client.GetSchema(groupName, name, version);
string definition = schema.Definition;


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.