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.
- Node.js version 8.x.x or higher
npm install @azure/schema-registry
Create and authenticate a
To create a client object to access the Schema Registry API, you will need the
endpoint of your Schema Registry resource and a
credential. The Schema
Registry client uses Azure Active Directory credentials to authenticate.
You can authenticate with Azure Active Directory using the Azure Identity
library. To use the
DefaultAzureCredential provider shown below, or other
credential providers provided with the Azure SDK, please install the
npm install @azure/identity
Set the values of the client ID, tenant ID, and client secret of the AAD
application as environment variables:
const DefaultAzureCredential = ;const SchemaRegistryClient = ;const client = "<endpoint>" ;
SchemaRegistryClient provides the API for storing and retrieving schemas in
is a separate package that uses
SchemaRegistryClientto pair schema ID along with Avro Binary Encoding.
Register a schema
const DefaultAzureCredential = ;const SchemaRegistryClient = ;const client = "<endpoint>" ;const description =name: "<name>"group: "<group>"serializationType: "<serialization type>"content: "<schema content>"const registered = await client;console;
Get ID of existing schema
const DefaultAzureCredential = ;const SchemaRegistryClient = ;const client = "<endpoint>" ;const description =name: "<name>"group: "<group>"serializationType: "<serialization type>"content: "<schema content>"const found = await client;console;
Get content of existing schema by ID
const DefaultAzureCredential = ;const SchemaRegistryClient = ;const client = "<endpoint>" ;const foundSchema = await client;console;
Enabling logging may help uncover useful information about failures. In order to
see a log of HTTP requests and responses, set the
info. Alternatively, logging can be enabled at runtime by calling
setLogLevel in the
const setLogLevel = ;;
Please take a look at the samples directory for detailed examples on how to use this library.
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 https://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.
If you'd like to contribute to this library, please read the contributing guide to learn more about how to build and test the code.