Azure.Data.SchemaRegistry
1.4.0
Prefix Reserved
dotnet add package Azure.Data.SchemaRegistry --version 1.4.0
NuGet\Install-Package Azure.Data.SchemaRegistry -Version 1.4.0
<PackageReference Include="Azure.Data.SchemaRegistry" Version="1.4.0" />
paket add Azure.Data.SchemaRegistry --version 1.4.0
#r "nuget: Azure.Data.SchemaRegistry, 1.4.0"
// Install Azure.Data.SchemaRegistry as a Cake Addin #addin nuget:?package=Azure.Data.SchemaRegistry&version=1.4.0 // Install Azure.Data.SchemaRegistry as a Cake Tool #tool nuget:?package=Azure.Data.SchemaRegistry&version=1.4.0
Azure Schema Registry client library for .NET
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
Prerequisites
- An Azure subscription
- An Event Hubs namespace
- A Schema Group of the correct serialization type
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 authenticated credentials and start interacting with Azure resources, please see the getting started with Azure Identity guide.
Get Event Hubs namespace hostname
The simplest 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,
// including AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, and AZURE_TENANT_ID.
// For more information on Azure.Identity usage, see: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md
string fullyQualifiedNamespace = "{hostname}.servicebus.windows.net";
var client = new SchemaRegistryClient(fullyQualifiedNamespace: fullyQualifiedNamespace, credential: new DefaultAzureCredential());
Key concepts
Schemas
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
Examples
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 groupName = "<schema_group_name>";
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 groupName = "<schema_group_name>";
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.
var schemaId = "<schema_id>";
SchemaRegistrySchema schema = client.GetSchema(schemaId);
string definition = schema.Definition;
string groupName = "<schema_group_name>";
string name = "<schema_id>";
int version = 1;
SchemaRegistrySchema schema = client.GetSchema(groupName, name, version);
string definition = schema.Definition;
Troubleshooting
Information on troubleshooting steps will be provided as potential issues are discovered.
Next steps
See Azure Schema Registry for additional information.
Contributing
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 cla.microsoft.com.
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 opencode@microsoft.com with any additional questions or comments.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Azure.Core (>= 1.43.0)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Azure.Data.SchemaRegistry:
Package | Downloads |
---|---|
Microsoft.Azure.Data.SchemaRegistry.ApacheAvro
Microsoft Azure Schema Registry Apache Avro SDK |
|
Microsoft.Azure.Kafka.SchemaRegistry.Avro
Azure Schema Registry is a hosted schema repository service provided by Azure Event Hubs, designed to simplify schema management and data governance. |
|
AtlasEvents
Package Description |
|
EventProducer
A SDK for producing events for Cheetah |
|
Microsoft.Azure.Kafka.SchemaRegistry.Json
Azure Schema Registry is a hosted schema repository service provided by Azure Event Hubs, designed to simplify schema management and data governance. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.4.0 | 10,567 | 9/18/2024 |
1.4.0-beta.2 | 20,830 | 8/9/2023 |
1.4.0-beta.1 | 1,428 | 1/17/2023 |
1.3.0 | 233,159 | 10/11/2022 |
1.2.0 | 343,185 | 5/11/2022 |
1.1.0 | 60,371 | 1/25/2022 |
1.0.0 | 25,690 | 11/11/2021 |
1.0.0-beta.4 | 10,188 | 10/6/2021 |
1.0.0-beta.3 | 1,957 | 8/17/2021 |
1.0.0-beta.2 | 58,372 | 9/23/2020 |
1.0.0-beta.1 | 29,180 | 9/9/2020 |