Azure Blob CSV: Folders Become Kafka Topics
Kafka Connect reads CSV blobs from Azure Blob Storage and routes each folder to its own topic, with storage credentials injected at startup from a git-ignored .env.
Overview
You upload a CSV to a folder in Azure Blob Storage. On the next poll, each row is a JSON message on a Kafka topic chosen by that folder.
Think of the container as a shared dropbox and each folder as a labeled tray.
input/employees/ is the employee tray. input/new_hires/ is the new-hire
tray. topic.regex.list is the label: match the blob path, publish to that
topic. The files never land on the Connect worker’s disk.
This is the remote version of the Spooldir CSV demo. The walkthrough lives in azure-blob-csv-connector inside the kafkaDemos repo.
How it works
./start-demo.sh reads a git-ignored .env, starts Compose, waits until the
Azure Blob Storage Source plugin is loaded, and PUTs the connector config with
the account name and either the account key or a SAS token filled in. The
checked-in connector-config.json keeps a placeholder. Credentials stay in
the environment.
./upload-csv.sh pushes a local file with a one-shot Azure CLI container:
./upload-csv.sh sample_data.csv employees # -> employee-data
./upload-csv.sh new_hires.csv new_hires # -> new-hires
./upload-csv.sh ---> csv-data / input/<folder>/*.csv
|
v
Azure Blob Storage Source (GENERIC, CSV)
|
topic.regex.list +-- input/employees/ ---> [employee-data]
+-- input/new_hires/ ---> [new-hires]
|
v
Connect offsets topic (blob already read)
| Blob path | Topic |
|---|---|
csv-data/input/employees/*.csv |
employee-data |
csv-data/input/new_hires/*.csv |
new-hires |
anything else, such as csv-data/input/x.csv |
skipped |
The regex is matched against the full path (input/employees/file.csv).
Patterns stay non-overlapping. Every file uses the same CSV settings, and each
file’s own header row supplies its field names, so two files can have
different columns.
A row comes through with string values:
{
"ID": "1",
"Name": "Alice Smith",
"Department": "Engineering",
"Salary": "85000"
}
Watch either topic in Kafka UI on localhost:8080, or
with kafka-console-consumer on employee-data or new-hires.
What it demonstrates
- A commercial connector on a trial. Confluent’s Azure Blob Storage Source
runs on
cp-server-connect8.3.2. That image provides the licensing classes.confluent.licenseis empty, so the connector runs on the 30-day trial. - Folder routing. One connector, two topics, decided by
topic.regex.list. - Secrets kept out of git.
.envholdsAZURE_STORAGE_ACCOUNTplusAZURE_STORAGE_KEYorAZURE_STORAGE_SAS_TOKEN.start-demo.shinjects them at create time. - Offsets instead of moving blobs. The connector records how far it has
read in the Connect offsets topic, keyed by connector name. A new file shows
up on the next poll (
azblob.poll.interval.msis 10 seconds).
Technical details
- Images:
confluentinc/cp-kafka:8.3.2(KRaft, broker and controller),confluentinc/cp-server-connect:8.3.2,provectuslabs/kafka-ui. Hub install:confluentinc/kafka-connect-azure-blob-storage-source:3.1.9. - Mode and format:
GENERIC, format classio.confluent.connect.cloud.storage.source.format.CloudStorageCsvFormat,csv.first.row.as.header=true. Container namecsv-data,topics.dirinput. - Routing string:
employee-data:input/employees/.*\.csv,new-hires:input/new_hires/.*\.csv. - Converters: string key, JSON value, value schemas disabled.
- Uploads:
upload-csv.shrunsdocker compose runon theazure-cliservice (Compose profiletools) and writesinput/<folder>/<name>_<timestamp>.csv. A SAS token used for upload needs Write. The connector itself needs Read and List. - Update in place: the start script PUTs
/connectors/azure-blob-csv-connector/config, so a second run applies config changes to the existing connector.jqis required.
curl http://localhost:8083/connectors/azure-blob-csv-connector/status | jq
./stop-demo.sh
Challenges & lessons
- This connector needs
cp-server-connect. The communitycp-kafka-connectimage does not ship the licensing classes the connector depends on. With no license key, you get the 30-day trial. - The account name in git is a placeholder.
connector-config.jsonstores"<set from AZURE_STORAGE_ACCOUNT>".start-demo.shrefuses to run until the account and a key or SAS token are in the environment or in.env, then writes them only into the live config. - The same connector name remembers what it already read. Deleting and
recreating
azure-blob-csv-connectordoes not republish old blobs. Give it a new name, or clear its offsets. New blobs are still picked up on the 10 second poll. - The regex sees the path, not the file name.
input/employees/file.csvmatchesemployee-data. A file that matches no pattern is skipped. Add a topic by adding anothertopic:regexpair and running./start-demo.shagain. - CSV values arrive as strings.
Salaryis"85000". The Spooldir demo sample output shows those fields as numbers, because that connector has schema generation turned on.