@azure/schema-registry v1.2.0
Azure Schema Registry client library for JavaScript
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
- Node.js version 8.x.x or higher
Prerequisites
- An Azure subscription
- An existing Schema Registry resource
Install the @azure/schema-registry
package
Install the Azure Text Analytics client library for JavaScript with npm
:
npm install @azure/schema-registry
Create and authenticate a SchemaRegistryClient
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
@azure/identity
package:
npm install @azure/identity
Set the values of the client ID, tenant ID, and client secret of the AAD
application as environment variables: AZURE_CLIENT_ID
, AZURE_TENANT_ID
,
AZURE_CLIENT_SECRET
.
const { DefaultAzureCredential } = require("@azure/identity");
const { SchemaRegistryClient } = require("@azure/schema-registry");
const client = new SchemaRegistryClient("<endpoint>", new DefaultAzureCredential());
Key concepts
SchemaRegistryClient
SchemaRegistryClient
provides the API for storing and retrieving schemas in
schema registry.
SchemaRegistry serializers
- @azure/schema-registry-avro
is a separate package that uses
SchemaRegistryClient
to pair schema ID along with Avro Binary Encoding.
Examples
Register a schema
const { DefaultAzureCredential } = require("@azure/identity");
const { SchemaRegistryClient } = require("@azure/schema-registry");
const client = new SchemaRegistryClient("<endpoint>", new DefaultAzureCredential());
const description = {
name: "<name>",
group: "<group>",
serializationType: "<serialization type>"
content: "<schema content>"
}
const registered = await client.registerSchema(description);
console.log(registered.id);
Get ID of existing schema
const { DefaultAzureCredential } = require("@azure/identity");
const { SchemaRegistryClient } = require("@azure/schema-registry");
const client = new SchemaRegistryClient("<endpoint>", new DefaultAzureCredential());
const description = {
name: "<name>",
group: "<group>",
serializationType: "<serialization type>"
content: "<schema content>"
}
const found = await client.getSchemaId(description);
console.log(`Got schema ID=${found.id}`);
Get content of existing schema by ID
const { DefaultAzureCredential } = require("@azure/identity");
const { SchemaRegistryClient } = require("@azure/schema-registry");
const client = new SchemaRegistryClient("<endpoint>", new DefaultAzureCredential());
const foundSchema = await client.getSchemaById("<id>");
console.log(`Got schema content=${foundSchema.content}`);
Troubleshooting
Logging
Enabling logging may help uncover useful information about failures. In order to
see a log of HTTP requests and responses, set the AZURE_LOG_LEVEL
environment
variable to info
. Alternatively, logging can be enabled at runtime by calling
setLogLevel
in the @azure/logger
:
const { setLogLevel } = require("@azure/logger");
setLogLevel("info");
Next steps
Please take a look at the samples directory for detailed examples on how to use this library.
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 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.
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.
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.
Related projects
3 days ago
5 days ago
7 days ago
11 days ago
12 days ago
10 days ago
13 days ago
14 days ago
17 days ago
18 days ago
19 days ago
20 days ago
21 days ago
24 days ago
25 days ago
26 days ago
27 days ago
28 days ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
2 months ago
2 months ago
3 months ago
3 months ago
4 months ago
4 months ago
4 months ago
5 months ago
6 months ago
6 months ago
7 months ago
7 months ago
8 months ago
9 months ago
8 months ago
7 months ago
8 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago