azure-docs-sdk-java/docs-ref-autogen/com.azure.data.schemaregist...

16 строки
6.8 KiB
YAML

### YamlMime:JavaPackage
uid: "com.azure.data.schemaregistry"
fullName: "com.azure.data.schemaregistry"
name: "com.azure.data.schemaregistry"
summary: "[Azure Schema Registry][] is a service in Microsoft Azure that enables users to manage the schemas for their applications and data.\n\n\n[Azure Schema Registry]: https://learn.microsoft.com/azure/event-hubs/schema-registry-overview"
classes:
- "com.azure.data.schemaregistry.SchemaRegistryAsyncClient"
- "com.azure.data.schemaregistry.SchemaRegistryClient"
- "com.azure.data.schemaregistry.SchemaRegistryClientBuilder"
enums:
- "com.azure.data.schemaregistry.SchemaRegistryVersion"
desc: "[Azure Schema Registry][] is a service in Microsoft Azure that enables users to manage the schemas for their applications and data. A schema is a formal definition of the structure of data in a particular format, such as Avro or JSON. With Azure Schema Registry, users can store, version, and manage these schemas in a central location, making it easier to ensure consistency and compatibility across different applications and systems.\n\nIn addition, Azure Schema Registry can integrate with other Azure services, such as Azure Event Hubs and Azure Stream Analytics, to provide a complete data processing and analytics solution. By using Azure Schema Registry, users can simplify the management of their data schemas, reduce errors and inconsistencies, and accelerate the development of data-driven applications.\n\nThe Azure Schema Registry client library allows Java developers to interact with Azure Schema Registry. It provides a set of APIs that enable Java developers to perform operations such as registering, updating, and retrieving schemas from the Azure Schema Registry.\n\n## Key Concepts ##\n\n * **Schema:** Text describing the how to deserialize and serialize an object.\n * **Schema Registry:** Centralized location for event producers and consumers to fetch schemas used to serialize and deserialized structured data.\n\n## Getting Started ##\n\nService clients are the point of interaction for developers to use Azure Schema Registry. <xref uid=\"com.azure.data.schemaregistry.SchemaRegistryClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"com.azure.data.schemaregistry.SchemaRegistryClient\"></xref> is the synchronous service client and <xref uid=\"com.azure.data.schemaregistry.SchemaRegistryAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"com.azure.data.schemaregistry.SchemaRegistryAsyncClient\"></xref> is the asynchronous service client. The examples shown in this document use a credential object named DefaultAzureCredential for authentication, which is appropriate for most scenarios, including local development and production environments. Additionally, we recommend using [managed identity][] for authentication in production environments. You can find more information on different ways of authenticating and their corresponding credential types in the [Azure Identity documentation\"][Azure Identity documentation].\n\n**Sample: Construct a service client**\n\nThe following code sample demonstrates the creation of the synchronous client <xref uid=\"com.azure.data.schemaregistry.SchemaRegistryClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"com.azure.data.schemaregistry.SchemaRegistryClient\"></xref>. The `fullyQualifiedNamespace` is the Event Hubs Namespace's host name. It is listed under the \"Essentials\" panel after navigating to the Event Hubs Namespace via Azure Portal. The credential used is `DefaultAzureCredential` because it combines commonly used credentials in deployment and development and chooses the credential to used based on its running environment.\n\n```java\nDefaultAzureCredential azureCredential = new DefaultAzureCredentialBuilder()\n .build();\n SchemaRegistryClient client = new SchemaRegistryClientBuilder()\n .fullyQualifiedNamespace(\"https://<your-schema-registry-endpoint>.servicebus.windows.net\")\n .credential(azureCredential)\n .buildClient();\n```\n\n## Using the Client ##\n\nThe samples below use the synchronous client, <xref uid=\"com.azure.data.schemaregistry.SchemaRegistryClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"com.azure.data.schemaregistry.SchemaRegistryClient\"></xref>. More samples can be found in the class's Javadoc. In addition, samples using the asynchronous <xref uid=\"com.azure.data.schemaregistry.SchemaRegistryAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"com.azure.data.schemaregistry.SchemaRegistryAsyncClient\"></xref> can be found in the class's JavaDocs.\n\n**Sample: Register a schema**\n\nThe following code sample demonstrates registering an Avro schema. The <xref uid=\"com.azure.data.schemaregistry.models.SchemaProperties\" data-throw-if-not-resolved=\"false\" data-raw-source=\"com.azure.data.schemaregistry.models.SchemaProperties\"></xref> returned contains the schema's id. This id uniquely identifies the schema and can be used to quickly associate payloads with that schema.\n\n```java\nString schema = \"{\\\"type\\\":\\\"enum\\\",\\\"name\\\":\\\"TEST\\\",\\\"symbols\\\":[\\\"UNIT\\\",\\\"INTEGRATION\\\"]}\";\n SchemaProperties properties = client.registerSchema(\"{schema-group}\", \"{schema-name}\", schema,\n SchemaFormat.AVRO);\n\n System.out.printf(\"Schema id: %s, schema format: %s%n\", properties.getId(), properties.getFormat());\n```\n\n**Sample: Getting the schema using a schema id**\n\nThe following code sample demonstrates how to fetch a schema using its schema id. The schema id can be found in <xref uid=\"com.azure.data.schemaregistry.models.SchemaProperties.getId()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"com.azure.data.schemaregistry.models.SchemaProperties#getId()\"></xref> when a schema is registered or using <xref uid=\"com.azure.data.schemaregistry.SchemaRegistryClient.getSchemaProperties(java.lang.String,java.lang.String,java.lang.String,com.azure.data.schemaregistry.models.SchemaFormat)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"com.azure.data.schemaregistry.SchemaRegistryClient#getSchemaProperties(java.lang.String, java.lang.String, java.lang.String, com.azure.data.schemaregistry.models.SchemaFormat)\"></xref>.\n\n```java\nSchemaRegistrySchema schema = client.getSchema(\"{schema-id}\");\n\n System.out.printf(\"Schema id: %s, schema format: %s%n\", schema.getProperties().getId(),\n schema.getProperties().getFormat());\n System.out.println(\"Schema contents: \" + schema.getDefinition());\n```\n\n\n[Azure Schema Registry]: https://learn.microsoft.com/azure/event-hubs/schema-registry-overview\n[managed identity]: https://learn.microsoft.com/azure/active-directory/managed-identities-azure-resources/\n[Azure Identity documentation]: https://learn.microsoft.com/java/api/overview/azure/identity-readme"
metadata: {}
package: "com.azure.data.schemaregistry"
artifact: com.azure:azure-data-schemaregistry:1.5.1