@azure/schema-registry-avro v1.1.0
Azure Schema Registry Avro serializer client library for JavaScript
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
- Node.js version 8.x.x or higher
Prerequisites
- An Azure subscription
- An existing Schema Registry resource
Install the @azure/schema-registry-avro
package
Install the Azure Text Analytics client library for JavaScript with npm
:
npm install @azure/schema-registry-avro
Key concepts
SchemaRegistryAvroSerializer
Provides API to serialize to and deserialize from Avro Binary Encoding plus a
header with schema ID. Uses
SchemaRegistryClient
from the @azure/schema-registry package
to get schema IDs from schema content or vice versa.
Message format
The same format is used by schema registry serializers across Azure SDK languages.
Messages are encoded as follows:
4 bytes: Format Indicator
- Currently always zero to indicate format below.
32 bytes: Schema ID
- UTF-8 hexadecimal representation of GUID.
- 32 hex digits, no hyphens.
- Same format and byte order as string from Schema Registry service.
Remaining bytes: Avro payload (in general, format-specific payload)
- Avro Binary Encoding
- NOT Avro Object Container File, which includes the schema and defeats the purpose of this serialzer to move the schema out of the message payload and into the schema registry.
Examples
Serialize and deserialize
const { DefaultAzureCredential } = require("@azure/identity");
const { SchemaRegistryClient } = require("@azure/schema-registry");
const { SchemaRegistryAvroSerializer } = require("@azure/schema-registry-avro");
const client = new SchemaRegistryClient("<endpoint>", new DefaultAzureCredential());
const serializer = new SchemaRegistryAvroSerializer(client, "<group>");
// Example Avro schema
const schema = JSON.stringify({
type: "record",
name: "Rating",
namespace: "my.example",
fields: [{ name: "score", type: "int" }]
});
// Example value that matches the Avro schema above
const value = { score: 42 };
// Serialize value to buffer
const buffer = await serializer.serialize(value, schema);
// Deserialize buffer to value
const deserializedValue = await serializer.deserialize(buffer);
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
2 days ago
4 days ago
6 days ago
11 days ago
9 days ago
10 days ago
12 days ago
13 days ago
16 days ago
17 days ago
18 days ago
19 days ago
20 days ago
23 days ago
24 days ago
25 days ago
26 days ago
27 days ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
2 months ago
2 months ago
2 months ago
3 months ago
3 months ago
3 months ago
4 months ago
4 months ago
4 months ago
5 months ago
6 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
8 months ago
8 months ago
7 months ago
9 months ago
8 months ago
1 year ago
12 months 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
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
3 years ago
2 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
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
4 years ago
4 years ago