Azure Blob Storage Source Connector for Confluent Cloud

The fully-managed Azure Storage Source connector for Confluent Cloud reads data from Azure Blob Storage and produces the data as records in Apache Kafka®. The connector can read from any file naming convention listed in Azure Blob Storage. The file names don’t have to be in a specific format, as long as the files are in a supported format. Supported formats include JSON, Avro, String, and Byte Array.

Note

Features

The Azure Blob Storage Source connector provides the following features:

  • At least once delivery: The connector guarantees that records are delivered at least once.
  • Supports multiple tasks: The connector supports running one or more tasks.
  • Generalized data format support: The connector supports reading data from Azure Blob Storage in Avro, JSON, String, and Bytes format. Besides records with schemas, the connector supports importing schemaless JSON records in text files, one record per line. In general, the connector accepts any format that provides an implementation of the Format interface.
  • Offset management capabilities: Supports offset management. For more information, see Manage custom offsets.

For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Connect Usage Examples section.

Limitations

Be sure to review the following information.

Manage custom offsets

You can manage the offsets for this connector. Offsets provide information on the point in the system from which the connector is accessing data. For more information, see Manage Offsets for Fully-Managed Connectors in Confluent Cloud.

To manage offsets:

To get the current offset, make a GET request that specifies the environment, Kafka cluster, and connector name.

GET /connect/v1/environments/{environment_id}/clusters/{kafka_cluster_id}/connectors/{connector_name}/offsets
Host: https://api.confluent.cloud

Response:

Successful calls return HTTP 200 with a JSON payload that describes the offset.

{
    "id": "lcc-example123",
    "name": "{connector_name}",
    "offsets": [
        {
          "partition": {
            "taskId": "lcc-example123-0-in_progress"
          },
          "offset": {
            "earliestIncomplete": "2023-08-03T10:24:25Z",
            "completedFiles": "[{\"filePath\":\"topics/abc_0/partition=0/abc_0+0+00000.json\",\"creationTime\":\"2023-08-03T10:24:25Z\"},{\"filePath\":\"topics/abc_1/partition=0/abc_1+0+00000.json\",\"creationTime\":\"2023-08-03T10:34:56Z\"},{\"filePath\":\"topics/abc_3/partition=0/abc_3+0+00000.json\",\"creationTime\":\"2023-08-03T10:48:28Z\"}]",
            "recordNum": "98"
          }
        }
        {
          "partition": {
            "taskId": "lcc-example123-1"
          },
          "offset": {
            "earliestIncomplete": "2023-08-03T10:24:25Z",
            "completedFiles": "[{\"filePath\":\"topics/babc_4/partition=0/babc_4+0+00000.json\",\"creationTime\":\"2023-08-03T10:33:04Z\"},{\"filePath\":\"topics/abc_2/partition=0/abc_2+0+00000.json\",\"creationTime\":\"2023-08-03T10:46:06Z\"},{\"filePath\":\"topics/weird/partition=0/weird+0+00000 copy.json\",\"creationTime\":\"2023-08-03T10:51:09Z\"}]",
            "recordNum": "99"
          }
        }
        {
          "partition": {
            "taskId": "lcc-example123-0"
          },
          "offset": {
            "earliestIncomplete": "2023-08-03T10:24:25Z",
            "completedFiles": "[{\"filePath\":\"topics/abc_0/partition=0/abc_0+0+00000.json\",\"creationTime\":\"2023-08-03T10:24:25Z\"},{\"filePath\":\"topics/abc_1/partition=0/abc_1+0+00000.json\",\"creationTime\":\"2023-08-03T10:34:56Z\"},{\"filePath\":\"topics/abc_3/partition=0/abc_3+0+00000.json\",\"creationTime\":\"2023-08-03T10:48:28Z\"},{\"filePath\":\"topics/abc_5/partition=0/abc_5+0+00000.json\",\"creationTime\":\"2023-08-03T10:59:06Z\"}]",
            "recordNum": "99"
          }
        }
        {
          "partition": {
            "taskId": "lcc-example123-1-in_progress"
          },
          "offset": {
            "earliestIncomplete": "2023-08-03T10:24:25Z",
            "completedFiles": "[{\"filePath\":\"topics/babc_4/partition=0/babc_4+0+00000.json\",\"creationTime\":\"2023-08-03T10:33:04Z\"},{\"filePath\":\"topics/abc_2/partition=0/abc_2+0+00000.json\",\"creationTime\":\"2023-08-03T10:46:06Z\"}]",
            "recordNum": "98"
          }
        }
    ],
    "metadata": {
        "observed_at": "2024-03-28T17:57:48.139635200Z"
    }
}

Responses include the following information:

  • The position of latest offset.
  • The observed time of the offset in the metadata portion of the payload. The observed_at time indicates a snapshot in time for when the API retrieved the offset. A running connector is always updating its offsets. Use observed_at to get a sense for the gap between real time and the time at which the request was made. By default, offsets are observed every minute. Calling GET repeatedly will fetch more recently observed offsets.
  • Information about the connector.

JSON payload

The table below offers a description of the unique fields in the JSON payload for managing offsets of the object store connectors, including the following connectors:

  • Amazon S3 Source connector
  • Azure Blob Storage Source connector
  • Google Cloud Storage (GCS) Source connector
Field Definition Required/Optional
taskId

Represents the partition in the following format: connector-name-<taskid>[-in-progress]

  • connector-name is the name of the connector.
  • taskid is the task id.
  • in-progress is conditional and only appears if a file is currently being sourced. After the file is processed, the file appears listed in completedFiles.
Required
earliestIncomplete The position of the latest offset. When a connectors starts or restarts, the connector reads the files with a creation time equal to or after earliestIncomplete offset. These files are sorted by creation time then filename. Required
completedFiles List of sourced files. Required
recordNum Number of records sourced. Required

Quick Start

Use this quick start to get up and running with the Confluent Cloud Azure Blob Storage Source connector. The quick start provides the basics of selecting the connector and configuring it to get data from an Azure Blob Storage container.

Prerequisites
  • Kafka cluster credentials. The following lists the different ways you can provide credentials.
    • Enter an existing service account resource ID.
    • Create a Confluent Cloud service account for the connector. Make sure to review the ACL entries required in the service account documentation. Some connectors have specific ACL requirements.
    • Create a Confluent Cloud API key and secret. To create a key and secret, you can use confluent api-key create or you can autogenerate the API key and secret directly in the Cloud Console when setting up the connector.

Using the Confluent Cloud Console

Step 1: Launch your Confluent Cloud cluster

See the Quick Start for Confluent Cloud for installation instructions.

Step 2: Add a connector

In the left navigation menu, click Connectors. If you already have connectors in your cluster, click + Add connector.

Step 3: Select your connector

Click the Azure Blob Storage Source connector card.

Azure Blob Storage Source Card

Step 4: Enter the connector details

Note

  • Be sure you have all your prerequisites completed.
  • An asterisk ( * ) designates a required entry.
  1. Select the way you want to provide Kafka Cluster credentials. You can choose one of the following options:
    • My account: This setting allows your connector to globally access everything that you have access to. With a user account, the connector uses an API key and secret to access the Kafka cluster. This option is not recommended for production.
    • Service account: This setting limits the access for your connector by using a service account. This option is recommended for production.
    • Use an existing API key: This setting allows you to specify an API key and a secret pair. You can use an existing pair or create a new one. This method is not recommended for production environments.
  2. Click Continue.

Step 5: Check the Kafka topic

After the connector is running, verify that messages are populating your Kafka topic.

Note

The Azure Blob Storage Source connector loads and filters all object names in the container before it starts sourcing records. When starting up, the connector may display RUNNING but not show any throughput. This is because container loading is not finished. For a container with a large amount of objects, loading can take several minutes to complete.

For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Connect Usage Examples section.

Using the Confluent CLI

Complete the following steps to set up and run the connector using the Confluent CLI.

Note

Make sure you have all your prerequisites completed.

Step 1: List the available connectors

Enter the following command to list available connectors:

confluent connect plugin list

Step 2: List the connector configuration properties

Enter the following command to show the connector configuration properties:

confluent connect plugin describe <connector-plugin-name>

The command output shows the required and optional configuration properties.

Step 3: Create the connector configuration file

Create a JSON file that contains the connector configuration properties. The following example shows the required connector properties.

{
  "connector.class": "AzureBlobSource",
  "name": "AzureBlobSourceConnector_0",
  "topic.regex.list": "kafka-topic-for-json:*",
  "kafka.auth.mode": "SERVICE_ACCOUNT",
  "kafka.service.account.id": "<service-account-resource-ID>",
  "azblob.account.name": "<storage-account-name>",
  "azblob.account.key": "<storage-account-key>",
  "azblob.container.name": "<container-name>",
  "input.data.format": "JSON",
  "tasks.max": "1",
}

Note the following required property definitions:

  • "connector.class": Identifies the connector plugin name.
  • "name": Sets a name for your new connector.
  • "topic.regex.list": A list of topics along with a regex expression of the files which are to be sent to that topic. In the example above, "kafka- topic-for-json:.*" sends all files to "kafka-topic-for-json". The expression "special-topic:.*\.json+*"” sends only files ending with ".json" to "special-topic". The connector ignores (doesn’t source) other files not matching any patterns. The connector sends files that match multiple mappings to the first topic in the list that maps the file. In case of a single file abc.json, path returned by Azure client is the absolute path, so the regex would be special-topic:.*abc\.json.
  • "kafka.auth.mode": Identifies the connector authentication mode you want to use. There are two options: SERVICE_ACCOUNT or KAFKA_API_KEY (the default). To use an API key and secret, specify the configuration properties kafka.api.key and kafka.api.secret, as shown in the example configuration (above). To use a service account, specify the Resource ID in the property kafka.service.account.id=<service-account-resource-ID>. To list the available service account resource IDs, use the following command:

    confluent iam service-account list
    

    For example:

    confluent iam service-account list
    
       Id     | Resource ID |       Name        |    Description
    +---------+-------------+-------------------+-------------------
       123456 | sa-l1r23m   | sa-1              | Service account 1
       789101 | sa-l4d56p   | sa-2              | Service account 2
    
  • "azblob.account.name": The storage account name to use for the connector.

  • "azblob.account.key": The storage account key to use. For information about how to set these up, see Manage storage account access keys.

  • "azblob.container.name": The container name. Must be between three and 63 alphanumeric characters, and the character - can be used.

  • "input.data.format": Supports Avro, JSON (schemaless), String, or Bytes. A valid schema must be available in Schema Registry to use a schema-based message format, like Avro. Refer to Confluent Cloud connector limitations for additional information.

  • "tasks.max": The total number of tasks to run in parallel. More tasks may improve performance.

  • Transforms and Predicates: See the Single Message Transforms (SMT) documentation for details.

For configuration property values and descriptions, see Configuration Properties.

Step 4: Load the properties file and create the connector

Enter the following command to load the configuration and start the connector:

confluent connect cluster create --config-file <file-name>.json

For example:

confluent connect cluster create --config-file azure-blob-source-config.json

Example output:

Created connector AzureBlobSourceConnector_0 lcc-ix4dl

Step 5: Check the connector status

Enter the following command to check the connector status:

confluent connect cluster list

Example output:

ID          |       Name                   | Status  |  Type
+-----------+------------------------------+---------+--------+
lcc-ix4dl   | AzureBlobSourceConnector_0   | RUNNING | source

Step 6. Check the Kafka topic.

After the connector is running, verify records are populating the Kafka topic.

Note

The Azure Blob Storage Source connector loads and filters all object names in the container before it starts sourcing records. When starting up, the connector may display RUNNING but not show any throughput. This is because container loading is not finished. For a container with a large amount of objects, loading can take several minutes to complete.

For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Connect Usage Examples section.

Configuration Properties

Use the following configuration properties with the fully-managed connector. For self-managed connector property definitions and other details, see the connector docs in Self-managed connectors for Confluent Platform.

How should we connect to your data?

name

Sets a name for your connector.

  • Type: string
  • Valid Values: A string at most 64 characters long
  • Importance: high

Which topic(s) do you want to send data to?

topic.regex.list

A list of topics along with a regex expression of the files which are to be sent to that topic. For example: “my-topic:.*” will send all files to “my-topic”, while a list containing only the expression “special-topic:.*.json” will send only files starting with “.json” to “special-topic”, and all other files not matching any patterns will be ignored and not sourced. Files that match multiple mappings will be sent to the first topic in the list that maps the file.

  • Type: list
  • Importance: high

Schema Config

schema.context.name

Add a schema context name. A schema context represents an independent scope in Schema Registry. It is a separate sub-schema tied to topics in different Kafka clusters that share the same Schema Registry instance. If not used, the connector uses the default schema configured for Schema Registry in your Confluent Cloud environment.

  • Type: string
  • Default: default
  • Importance: medium

Kafka Cluster credentials

kafka.auth.mode

Kafka Authentication mode. It can be one of KAFKA_API_KEY or SERVICE_ACCOUNT. It defaults to KAFKA_API_KEY mode.

  • Type: string
  • Default: KAFKA_API_KEY
  • Valid Values: KAFKA_API_KEY, SERVICE_ACCOUNT
  • Importance: high
kafka.api.key

Kafka API Key. Required when kafka.auth.mode==KAFKA_API_KEY.

  • Type: password
  • Importance: high
kafka.service.account.id

The Service Account that will be used to generate the API keys to communicate with Kafka Cluster.

  • Type: string
  • Importance: high
kafka.api.secret

Secret associated with Kafka API key. Required when kafka.auth.mode==KAFKA_API_KEY.

  • Type: password
  • Importance: high

Azure Blob Storage details

azblob.account.name

Must be between 3-24 alphanumeric characters.

  • Type: string
  • Valid Values: A string at most 24 characters long
  • Importance: high
azblob.account.key

The Azure Storage account key.

  • Type: password
  • Importance: high
azblob.container.name

Please provide the Azure Blob Storage Container name. Must be between 3-63 alphanumeric and ‘-‘ characters.

  • Type: string
  • Importance: high
azblob.sas.token

Shared access signature (SAS) is a URI that grants restricted access rights to Azure Storage resources. Please provide a shared access signature to clients who should not be trusted with your storage account key but whom you wish to delegate access to certain storage account resources.

  • Type: password
  • Importance: medium
azblob.retry.type

The policy specifying the type of retry pattern to use. Should be either Exponential or Fixed.

  • Type: string
  • Default: EXPONENTIAL
  • Valid Values: EXPONENTIAL, FIXED
  • Importance: medium

Input and output messages

input.data.format

Sets the input message format. Valid entries are AVRO, JSON, BYTES or STRING. Note that you need to have Confluent Cloud Schema Registry configured if using a schema-based message format like AVRO.

  • Type: string
  • Valid Values: AVRO, BYTES, JSON, STRING
  • Importance: high
output.data.format

Set the output Kafka record value format. Valid entries are AVRO, JSON_SR, PROTOBUF, JSON or BYTES. Note that you need to have Confluent Cloud Schema Registry configured if using a schema-based message format like AVRO. Note that the output message format defaults to the value in the Input Message Format field. If no value for this property is provided, the value specified for the ‘input.data.format’ property is used.

  • Type: string
  • Importance: high

Storage

topics.dir

Top-level directory where data to be ingested is stored.

  • Type: string
  • Default: topics
  • Importance: high
directory.delim

Directory delimiter pattern.

  • Type: string
  • Default: /
  • Importance: medium
behavior.on.error

Should the task halt when it encounters an error or continue to the next file.

  • Type: string
  • Default: FAIL
  • Importance: high
format.bytearray.separator

String inserted between records for ByteArrayFormat. Defaults to n and may contain escape sequences like n. An input record that contains the line separator looks like multiple records in the storage object input.

  • Type: string
  • Default: “”
  • Importance: medium
task.batch.size

The number of files assigned to each task at a time

  • Type: int
  • Default: 10
  • Valid Values: [1,…,2000]
  • Importance: high
file.discovery.starting.timestamp

A unix timestamp (seconds since Jan 1, 1970 UTC) that denotes where to start processing files. Any file encountered with a creation time earlier than this will be ignored.

  • Type: long
  • Default: 0
  • Importance: high

Data polling policy

azblob.poll.interval.ms

Frequency in milliseconds to poll for new or removed folders. This may result in updated task configurations starting to poll for data in added folders or stopping polling for data in removed folders

  • Type: long
  • Default: 60000 (1 minute)
  • Valid Values: [1000,…]
  • Importance: medium
record.batch.max.size

The maximum amount of records to return each time storage is polled.

  • Type: int
  • Default: 200
  • Valid Values: [1,…,10000]
  • Importance: medium

Number of tasks for this connector

tasks.max

The total number of tasks to run in parallel.

  • Type: int
  • Valid Values: [1,…,1000]
  • Importance: high

Next Steps

For an example that shows fully-managed Confluent Cloud connectors in action with Confluent Cloud ksqlDB, see the Cloud ETL Demo. This example also shows how to use Confluent CLI to manage your resources in Confluent Cloud.

../_images/topology.png