Manage Schemas 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 the same environment (default) and cluster (e.g., My First Cluster) as for the Confluent Cloud Quick Start.

Enable Schema Registry for Confluent Cloud

To verify this, use the Confluent Cloud CLI
to run ccloud environment list and ccloud kafka cluster list. If you need more help on setting the active environment or cluster, see Confluent Cloud Quick Start and the Confluent Cloud CLI Command Reference.
  1. Log in to the Confluent Cloud UI at https://confluent.cloud.

  2. Click Schemas on the navigation bar.

  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.
    ../../_images/cloud-sr-enable.png
  4. Click Confirm to create the Schema Registry with these cloud provider and region settings, or click Cancel to go back and re-set.

    ../../_images/cloud-sr-provider-region.png
  5. Under Make requests to this Schema Registry endpoint, copy the Schema Registry endpoint to a safe location.

    ../../_images/cloud-sr-view1.png

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 Confluent Cloud Quick Start.
  • 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. Click the Manage API Keys button under step 1 to open the API access list of Schema Registry API keys.

    Screenshot of the Schema Registry page in Confluent Cloud
  2. Click Create key to create a new Schema Registry API key.

    Screenshot of the Create Schema Registry API Key page in Confluent Cloud
  3. On the Create a new Schema Registry API key dialog, copy the API Key and the API Secret to a safe location.

    Screenshot of a new Schema Registry key and secret in Confluent Cloud
  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 Schema Registry API Key page in Confluent Cloud listing newly created key

Create a Topic in Confluent Cloud

You will already have topics available, having worked through the prerequisite Confluent Cloud Quick Start, 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.

    Use the same cluster as for the Confluent Cloud Quick Start (e.g, My First Cluster).

  3. Click Topics on the left menu, then click + Add a 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 Confluent Cloud Quick Start 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 (e.g., the default t182).

    Enter your Confluent credentials:
    Email:
    Password:
    
    Using environment t2814 ("my-cloud-demos")
    
  2. Select the same environment (for this example, default) 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).

    ccloud environment list
    

    For example:

    ccloud environment list
    

    Your output should resemble:

    Id    |      Name
    +----------+----------------+
      * t1898  | default
        t2814  | my-cloud-demos
        t25500 | Test
    
    ccloud environment use t1898
    

    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, click a cluster, select a topic, and click the Schema tab. Select a schema format type from the drop-down menu (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.

    Screenshot of sample topic in Confluent Cloud
  3. Click Schema.

    Screenshot of sample topic in Confluent Cloud

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