|
| 1 | +--- |
| 2 | +title: Azure Schema Registry Concepts |
| 3 | +description: This article explains concepts for Azure Schema Registry in Azure Event Hubs. |
| 4 | +ms.topic: conceptual |
| 5 | +ms.date: 04/26/2023 |
| 6 | +author: kasun04 |
| 7 | +ms.author: kindrasiri |
| 8 | +--- |
| 9 | + |
| 10 | +# Schema Registry in Azure Event Hubs |
| 11 | +Schema Registry in Azure Event Hubs provides you with a repository to use and manage schemas in schema-driven event streaming scenarios. |
| 12 | + |
| 13 | +## Schema Registry components |
| 14 | + |
| 15 | +An Event Hubs namespace can host schema groups alongside event hubs (or Kafka topics). It hosts a schema registry and can have multiple schema groups. In spite of being hosted in Azure Event Hubs, the schema registry can be used universally with all Azure messaging services and any other message or events broker. Each of these schema groups is a separately securable repository for a set of schemas. Groups can be aligned with a particular application or an organizational unit. |
| 16 | + |
| 17 | +:::image type="content" source="./media/schema-registry-overview/elements.png" alt-text="Diagram that shows the components of Schema Registry in Azure Event Hubs." border="false"::: |
| 18 | + |
| 19 | +### Schema groups |
| 20 | +Schema group is a logical group of similar schemas based on your business criteria. A schema group can hold multiple versions of a schema. The compatibility enforcement setting on a schema group can help ensure that newer schema versions are backwards compatible. |
| 21 | + |
| 22 | +The security boundary imposed by the grouping mechanism help ensures that trade secrets don't inadvertently leak through metadata in situations where the namespace is shared among multiple partners. It also allows for application owners to manage schemas independent of other applications that share the same namespace. |
| 23 | + |
| 24 | +### Schemas |
| 25 | +Schemas define the contract between producers and consumers. A schema defined in an Event Hubs schema registry helps manage the contract outside of event data, thus removing the payload overhead. A schema has a name, type (example: record, array, and so on.), compatibility mode (none, forward, backward, full), and serialization type (only Avro for now). You can create multiple versions of a schema and retrieve and use a specific version of a schema. |
| 26 | + |
| 27 | +### Schema formats |
| 28 | +Schema formats are used to determine the manner in which a schema is structured and defined, with each format outlining specific guidelines and syntax for defining the structure of the events that will be used for event streaming. |
| 29 | + |
| 30 | +#### Avro schema |
| 31 | +[Avro](https://avro.apache.org/) is a popular data serialization system that uses a compact binary format and provides schema evolution capabilities. |
| 32 | + |
| 33 | +To learn more about using Avro schema format with Event Hubs Schema Registry, see: |
| 34 | +- [How to use schema registry with Kafka and Avro](schema-registry-kafka-java-send-receive-quickstart.md) |
| 35 | +- [ How to use Schema registry with Event Hubs .NET SDK (AMQP) and Avro.](schema-registry-dotnet-send-receive-quickstart.md) |
| 36 | + |
| 37 | +#### JSON Schema (Preview) |
| 38 | +[JSON Schema](https://json-schema.org/) is a standardized way of defining the structure and data types of the events. JSON Schema enables the confident and reliable use of the JSON data format in event streaming. |
| 39 | + |
| 40 | +To learn more about using JSON schema format with Event Hubs Schema Registry, see: |
| 41 | +- [How to use schema registry with Kafka and JSON Schema](schema-registry-json-schema-kafka.md) |
| 42 | + |
| 43 | +## Schema evolution |
| 44 | +Schemas need to evolve with the business requirement of producers and consumers. Azure Schema Registry supports schema evolution by introducing compatibility modes at the schema group level. When you create a schema group, you can specify the compatibility mode of the schemas that you include in that schema group. When you update a schema, the change should comply with the assigned compatibility mode and then only it creates a new version of the schema. |
| 45 | + |
| 46 | + > [!NOTE] |
| 47 | +> Schema evolution is only supported for Avro schema format only. |
| 48 | +
|
| 49 | +Azure Schema Registry for Event Hubs support following compatibility modes. |
| 50 | + |
| 51 | +### Backward compatibility |
| 52 | +Backward compatibility mode allows the consumer code to use a new version of schema but it can process messages with old version of the schema. When you use backward compatibility mode in a schema group, it allows following changes to be made on a schema. |
| 53 | + |
| 54 | +- Delete fields. |
| 55 | +- Add optional fields. |
| 56 | + |
| 57 | +### Forward compatibility |
| 58 | +Forward compatibility allows the consumer code to use an old version of the schema but it can read messages with the new schema. Forward compatibility mode allows following changes to be made on a schema. |
| 59 | +- Add fields |
| 60 | +- Delete optional fields |
| 61 | + |
| 62 | +### No compatibility |
| 63 | +When the ``None`` compatibility mode is used, the schema registry doesn't do any compatibility checks when you update schemas. |
| 64 | + |
| 65 | +## Client SDKs |
| 66 | + |
| 67 | +You can use one of the following libraries to include an Avro serializer, which you can use to serialize and deserialize payloads containing Schema Registry schema identifiers and Avro-encoded data. |
| 68 | + |
| 69 | +- [.NET - Microsoft.Azure.Data.SchemaRegistry.ApacheAvro](https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/schemaregistry/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro) |
| 70 | +- [Java - azure-data-schemaregistry-avro](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/schemaregistry/azure-data-schemaregistry-apacheavro) |
| 71 | +- [Python - azure-schemaregistry-avroserializer](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/schemaregistry/azure-schemaregistry-avroencoder/) |
| 72 | +- [JavaScript - @azure/schema-registry-avro](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/schemaregistry/schema-registry-avro) |
| 73 | +- [Apache Kafka](https://github.com/Azure/azure-schema-registry-for-kafka/) - Run Kafka-integrated Apache Avro serializers and deserializers backed by Azure Schema Registry. The Java client's Apache Kafka client serializer for the Azure Schema Registry can be used in any Apache Kafka scenario and with any Apache Kafka® based deployment or cloud service. |
| 74 | +- **Azure CLI** - For an example of adding a schema to a schema group using CLI, see [Adding a schema to a schema group using CLI](https://github.com/Azure/azure-event-hubs/tree/master/samples/Management/CLI/AddschematoSchemaGroups). |
| 75 | +- **PowerShell** - For an example of adding a schema to a schema group using PowerShell, see [Adding a schema to a schema group using PowerShell](https://github.com/Azure/azure-event-hubs/tree/master/samples/Management/PowerShell/AddingSchematoSchemagroups). |
| 76 | + |
| 77 | + |
| 78 | +## Limits |
| 79 | +For limits (for example: number of schema groups in a namespace) of Event Hubs, see [Event Hubs quotas and limits](event-hubs-quotas.md) |
| 80 | + |
| 81 | +## Azure role-based access control |
| 82 | +When accessing the schema registry programmatically, you need to register an application in Azure Active Directory (Azure AD) and add the security principal of the application to one of the following Azure role-based access control (Azure RBAC) roles: |
| 83 | + |
| 84 | +| Role | Description | |
| 85 | +| ---- | ----------- | |
| 86 | +| Owner | Read, write, and delete Schema Registry groups and schemas. | |
| 87 | +| Contributor | Read, write, and delete Schema Registry groups and schemas. | |
| 88 | +| [Schema Registry Reader](../role-based-access-control/built-in-roles.md#schema-registry-reader-preview) | Read and list Schema Registry groups and schemas. | |
| 89 | +| [Schema Registry Contributor](../role-based-access-control/built-in-roles.md#schema-registry-reader-preview) | Read, write, and delete Schema Registry groups and schemas. | |
| 90 | + |
| 91 | +For instructions on creating registering an application using the Azure portal, see [Register an app with Azure AD](../active-directory/develop/quickstart-register-app.md). Note down the client ID (application ID), tenant ID, and the secret to use in the code. |
| 92 | + |
| 93 | +## Next steps |
| 94 | + |
| 95 | +- To learn how to create a schema registry using the Azure portal, see [Create an Event Hubs schema registry using the Azure portal](create-schema-registry.md). |
| 96 | +- See the following **Schema Registry Avro client library** samples. |
| 97 | + - [.NET](https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/schemaregistry/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro/tests/Samples) |
| 98 | + - [Java](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples) |
| 99 | + - [JavaScript](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/schemaregistry/schema-registry-avro/samples ) |
| 100 | + - [Python](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/schemaregistry/azure-schemaregistry-avroencoder/samples) |
| 101 | + - [Kafka Avro Integration for Azure Schema Registry](https://github.com/Azure/azure-schema-registry-for-kafka/tree/master/csharp/avro/samples) |
0 commit comments