Quick Start for Schema Management on Confluent Cloud

You can use Confluent Cloud Schema Registry to manage schemas in Confluent Cloud. You enable a single Schema Registry per Confluent Cloud environment. Schema Registry is accessed over port 443.

You can create and edit schemas in a schema editor and associate them with Kafka topics.

Important

Log in to the Confluent Cloud UI

  1. Log in to Confluent Cloud at https://confluent.cloud.
  2. Select an environment or create a new one.

Enable Schema Registry for Confluent Cloud

  1. Select a cluster.

  2. Click the Schemas tab.

  3. Choose a cloud provider and region.

    • Select Amazon Web Services (AWS), Google Cloud Platform (GCP), or Azure
    • Choose a Region. US, Europe, and APAC are the available choices.
    • Click Enable Schema Registry.
    Screenshot of Cloud provider and region settings
  4. Review your settings, and click Confirm to create the Schema Registry with these cloud provider and region settings.

    Screenshot of Cloud provider and region settings

    An empty schemas list is shown, indicating no schemas have yet been created.

    Screenshot of empty schemas list at start of enabling Schema Registry for a Confluent Cloud environment

Create an API Key for Confluent Cloud Schema Registry

To use Confluent Cloud Schema Registry for managing Kafka clusters, you need an API key specific to Schema Registry.

Note

  • The API key for Confluent Cloud Schema Registry is distinct from the API key you created for Kafka clusters in the same environment, per the Quick Start for Apache Kafka using Confluent Cloud.
  • Confluent Cloud provides one Schema Registry per environment, and each environment can contain multiple Kafka clusters. You need an API key/secret pair for each Kafka cluster and another for the Schema Registry cluster.
  1. In the environment for which you want to set up Schema Registry, click the Settings tab, then click Schema Registry API access to expand those options.

    Screenshot of a new Schema Registry API access options
  2. Under Make requests to this Schema Registry endpoint, copy the Schema Registry endpoint to a safe location.

    Screenshot of Schema Registry Confluent Cloud setup a copy endpoint option
  3. Click Create key to create a new Schema Registry API key.

  4. When the API Key and API Secret are saved, click the checkbox next to I have saved my API key and secret and am ready to continue, and click Continue.

    Screenshot of a new Schema Registry key and secret in Confluent Cloud

    Your new Schema Registry key is shown on the Schema Registry API access key list.

    Screenshot of Schema Registry in Confluent Cloud listing newly created key

Tip

To learn more about other environment level schema management options available on the Environment settings page, see Configure and Manage Schemas for an Environment.

Create a Topic in Confluent Cloud

You may already have topics available on this cluster, having worked through the prerequisite Quick Start for Apache Kafka using Confluent Cloud, but create a new topic designed to test out Schema Registry.

  1. Select the environment.

    Tip

    If you have only one environment, default, it will be selected already.

  2. Select the cluster.

  3. Click Topics on the left menu, then click Create topic.

    Screenshot of new topic dialog in Confluent Cloud

    Name the new topic employees, and click Create with defaults to add it.

Create a Schema

Use the Confluent Cloud CLI to create the schema. If you need more help with the basic CLI commands, type ccloud --help, ccloud schema-registry --help to drill down, or see Quick Start for Apache Kafka using Confluent Cloud and the Confluent Cloud CLI Command Reference.

  1. Log in to the Confluent Cloud CLI.

    ccloud login
    

    Follow the prompts to enter your credentials (email and password).

    Upon login, Confluent Cloud indicates your current environment.

    Enter your Confluent credentials:
    Email:
    Password:
    
    Using environment t2814 ("my-cloud-demos")
    
  2. Select the environment where you created the employees topic. (It may already be selected upon login.)

    In order to verify this, use ccloud environment list to get the environment IDs, followed by ccloud environment use <ID> to select the environment you want (if it is not already the current environment).

    For example:

    ccloud environment list
    

    Your output should resemble:

    Id    |      Name
    +-------------+----------------+
      * t1898     | default
        t2814     | my-cloud-demos
        env-gw333 | my-new-env
    

    To use “my-new-env”:

    ccloud environment use env-gw333
    

    Tip

    • To list environments: ccloud environment list
    • To select an environment: ccloud environment use <environment ID>
    • To list clusters: ccloud kafka cluster list
    • To select a cluster: ccloud kafka cluster use <cluster ID>
    • For the full list of ccloud commands see Confluent Cloud CLI Command Reference.
  3. Create a file containing the following JSON and name it employees.json.

    {
       "type" : "record",
       "namespace" : "Example",
       "name" : "Employee",
       "fields" : [
          { "name" : "Name" , "type" : "string" },
          { "name" : "Age" , "type" : "int" }
       ]
    }
    
  4. Create a schema that uses employees.json.

    ccloud schema-registry schema create --subject employees-value --schema employees.json --type AVRO
    

    For example:

    ccloud schema-registry schema create --subject employees-value --schema employees.json --type AVRO
    
    Enter your Schema Registry API Key:
    xxxx
    Enter your Schema Registry API Secret:
    xxxxyyyyzzzz
    Successfully registered schema with ID: 100001
    

    Tip

    • You have the option to create schemas that reference other schemas by using the --refs <ref-file> flag with ccloud schema-registry schema create. To learn more about schema references, see Schema References in the Confluent Platform documentation.

    • You must specify a schema format type as one of AVRO, JSON, or PROTOBUF, and then supply a schema that conforms to the syntax for that type. To learn more about development using these schema formats, see Schema Formats, Serializers, and Deserializers in the Confluent Platform documentation, the JSON Schema project documentation, the Apache Avro® specification, and the Google Developer documentation on Protocol Buffers.

    • You can also create a schema on the Confluent Cloud web UI. To do so, select an environment and cluster, select a topic, then click the Schema tab for that topic. Select a schema format type (for this example, Avro), paste the schema (such as the employees.json content), and click Save.

      Create a schema and choose type in Confluent Cloud web UI

View the Topic and Associated Schema

Return to the Confluent Cloud UI to view the new schema for the employees topic.

  1. Navigate to the topics list for your cluster.

    Screenshot of sample topic in Confluent Cloud
  2. Click the employees topic you created in a previous step.

  3. Click Schema.

    Screenshot of sample schema in Confluent Cloud

    And there you have it! You have a new schema (employees-value) for the employees topic in Confluent Cloud Schema Registry.

Configure and Manage Schemas for an Environment

Several tasks related to schemas on Confluent Cloud are managed at the environment level. This includes creating and managing Schema Registry API keys along with options, as described below, to view and search schemas, monitor usage, and set a compatibility mode for schemas.

View and Search All Schemas in an Environment

To view a searchable list of all schemas available in a Confluent Cloud environment:

  1. Select an environment.

    Screenshot of environments in Confluent Cloud
  2. Click the Schemas tab.

    Screenshot of schemas list in Confluent Cloud

View Allowed Usage for Schemas on Confluent Cloud

Schema Registry in Confluent Cloud limits the number of schema versions supported in the registry for basic clusters, standard clusters, and dedicated clusters as described in Confluent Cloud Cluster Types. You can view the number of schemas you have in an environment compared to the allowed usage limit.

  1. Select an environment.

  2. Click the Settings tab.

  3. Click Schema Registry allowed usage to expand the usage view.

    Screenshot of allowed usage for schemas on Confluent Cloud

To learn more about how to manage schema usage on Confluent Cloud, see how to free up space for new schemas.

View and Edit Schema Compatibility Settings

The default compatibility mode is Backward. You can change the mode, which will apply to all schemas in an environment.

Caution

If you change the compatibility mode of existing schemas already in production use, be aware of any possible breaking changes to your applications.

  1. Select an environment.

  2. Click the Settings tab.

  3. Click Schema Registry compatibility configuration to expand the compatibility options.

    Screenshot of schema compatibility settings on Confluent Cloud
  4. Select a mode option:

    Descriptions indicate the compatibility behavior for each option. For more information, including the changes allowed for each option, see Schema Evolution and Compatibility.

  5. Click Save.

Use curl to View and Manage Schemas

You can also use curl commands to view and manage schemas on Confluent Cloud.

Schema Registry on Confluent Cloud requires that you pass the API Key and Secret with the --user (or -u) flag. For example, to view all subjects in the registry:

curl --user <schema-registry-api-key>:<schema-registry-api-secret> \
<schema-registry-url>/subjects

For more information about using curl commands with Schema Registry, see Schema Registry API Usage Examples. With the exception of this one same example, the examples are for on-premises Schema Registry but many of the commands are relevant to Confluent Cloud, once you know how to pass your API Key and Secret as shown here.