Cameleer

Azure Files component

The azure-storage-files component uploads, downloads, lists and deletes files and directories in Azure Files shares, and polls a directory for new files.

Scheme: azure-storage-files: · Crate: cameleer-cloud · Cargo feature: cloud · Consumer: yes · Producer: yes · Apache Camel: Camel's Azure Files component uses the scheme azure-files and FTP-style options; azure-storage-files follows the other Azure storage components and also supports those FTP-style options

When to use it

  • Exchange files with applications that mount an Azure file share (SMB) from a route.
  • Pick up files written to a share, then delete or move them.
  • Publish exports to a share with an atomic rename (tempPrefix).

URI format

text
azure-storage-files://accountName/shareName[?options]

Example

Upload an export into a directory of a share:

yaml example: azure-storage-files-upload-export
- route:
    id: export-to-share
    from:
      uri: "timer:export?repeatCount=1"
      steps:
        - setBody:
            constant: "sku,stock;A-1,12;B-7,0"
        - setHeader:
            name: CamelAzureStorageFilesFileName
            constant: stock.csv
        - to: "azure-storage-files://{{env:AZURE_STORAGE_ACCOUNT:mystorageaccount}}/exports?operation=uploadFile&directoryName=daily&accessKey=RAW({{env:AZURE_STORAGE_KEY:}})"
        - log: "uploaded daily/${header.CamelAzureStorageFilesFileName}"

Rust DSL

rust
ctx.add_routes(|b| {
    b.from("timer:export?repeatCount=1")
        .set_body(constant("sku,stock;A-1,12;B-7,0"))
        .set_header("CamelAzureStorageFilesFileName", constant("stock.csv"))
        .to("azure-storage-files://{{env:AZURE_STORAGE_ACCOUNT:mystorageaccount}}/exports?operation=uploadFile&directoryName=daily&accessKey=RAW({{env:AZURE_STORAGE_KEY:}})")
        .log("uploaded daily/${header.CamelAzureStorageFilesFileName}");
})?;

Options

Common Azure options (credentials, endpoint override, proxy) are described in Cloud credentials. Shared Key and SAS are supported.

optiondefaultdescription
operationlistDirectoriesAndFileslistShares, createShare, deleteShare, listDirectoriesAndFiles, createDirectory, deleteDirectory, uploadFile, downloadFile, getFileProperties, deleteFile, renameFile (Cameleer).
directoryNameshare rootDirectory.
fileNameFile (the CamelAzureStorageFilesFileName header wins).
prefixListing prefix.
maxMessagesPerPoll10Consumer: files per poll.
deletefalseConsumer: delete processed files (otherwise files already delivered, by name and ETag, are skipped).
recursive, minDepth, maxDepthfalseConsumer: descend into sub-directories.
include, excludeConsumer: regular expressions on file names.
noop, idempotent, idempotentKey, idempotentRepositoryfalseConsumer: leave files in place and remember them (idempotentKey=name-etag re-reads changed files).
preMove, move, moveFailedConsumer: rename files before processing, after success or after failure.
fileExistOverrideuploadFile when the file exists: Override, Append, Fail, Ignore, Move (into moveExisting).
tempPrefixUpload to a temporary name, then rename (atomic replace).
autoCreatetrueCreate missing directories of CamelFileName.
flattenfalseKeep only the last segment of the file name.

Message headers

headerdirectiondescription
CamelAzureStorageFilesOperationinOverrides operation.
CamelAzureStorageFilesShareName, CamelAzureStorageFilesDirectoryName, CamelAzureStorageFilesFileNamein/outLocation.
CamelAzureStorageFilesPrefix, CamelAzureStorageFilesContentTypeinListing prefix, content type.
CamelAzureStorageFilesContentLength, CamelAzureStorageFilesETag, CamelAzureStorageFilesLastModifiedoutFile properties.
CamelAzureStorageFilesRenameToinTarget of renameFile.
CamelFileName, CamelFileNameOnly, CamelFileParent, CamelFileRelativePath, CamelFileLengthoutConsumer file headers.

Run it with Docker

sh
docker run --rm -e AZURE_STORAGE_ACCOUNT -e AZURE_STORAGE_KEY \
  -v "$PWD:/routes:ro" pmsudhi/cameleer run /routes/export.camel.yaml

Common questions

How do I avoid readers seeing half-written files?

Set tempPrefix=.tmp-: the file is uploaded under a temporary name and renamed when complete.

Can I process files and keep them?

Yes: noop=true leaves them and remembers which ones were consumed (in memory, or in your idempotentRepository).

Found a problem?

If something on this page doesn't match what Cameleer does, or you hit a bug while building with it, please help fix it, whether you are a person or a coding agent: open an issue that describes what you saw, then fork the repository, fix it, add or update a test, run cargo test --workspace, and open a pull request. CONTRIBUTING.md explains the ground rules.

Edit this page on GitHub