Azure Blob Storage binding spec

To setup Azure Blob Storage binding create a component of type . See on how to create and apply a binding configuration.

Warning

The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described .

This component supports output binding with the following operations:

To perform a create blob operation, invoke the Azure Blob Storage binding with a POST method and the following JSON body:

  1. {
  2. "operation": "create",
  3. "data": "YOUR_CONTENT"
  4. }

Examples

Save text to a random generated UUID blob

On Windows, utilize cmd prompt (PowerShell has different escaping mechanism)

  1. curl -d "{ \"operation\": \"create\", \"data\": \"Hello World\" }" http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
  1. curl -d '{ "operation": "create", "data": "Hello World" }' \
  2. http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
Save text to a specific blob
  1. http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
Save a file to a blob

To upload a file, encode it as Base64 and let the Binding know to deserialize it:

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: <NAME>
  5. namespace: <NAMESPACE>
  6. spec:
  7. type: bindings.azure.blobstorage
  8. version: v1
  9. metadata:
  10. - name: storageAccount
  11. value: myStorageAccountName
  12. - name: storageAccessKey
  13. value: ***********
  14. - name: container
  15. value: container1
  16. - name: decodeBase64
  17. value: "true"

Then you can upload it as you would normally:

  1. curl -d "{ \"operation\": \"create\", \"data\": \"YOUR_BASE_64_CONTENT\", \"metadata\": { \"blobName\": \"my-test-file.jpg\" } }" http://localhost:<dapr-port>/v1.0/bindings/<binding-name>

Response

The response body will contain the following JSON:

  1. {
  2. "blobURL": "https://<your account name>. blob.core.windows.net/<your container name>/<filename>"

Get blob

  1. "operation": "get",
  2. "metadata": {
  3. "blobName": "myblob"
  4. }
  5. }

Example

  1. curl -d '{ \"operation\": \"get\", \"metadata\": { \"blobName\": \"myblob\" }}' http://localhost:<dapr-port>/v1.0/bindings/<binding-name>

Response

The response body contains the value stored in the blob object.

By default the Azure Blob Storage output binding auto generates a UUID as the blob filename and is not assigned any system or custom metadata to it. It is configurable in the metadata property of the message (all optional).

Applications publishing to an Azure Blob Storage output binding should send a message with the following format:

  1. {
  2. "data": "file content",
  3. "metadata": {
  4. "blobName" : "filename.txt",
  5. "ContentType" : "text/plain",
  6. "ContentMD5" : "vZGKbMRDAnMs4BIwlXaRvQ==",
  7. "ContentEncoding" : "UTF-8",
  8. "ContentLanguage" : "en-us",
  9. "ContentDisposition" : "attachment",
  10. "CacheControl" : "no-cache",
  11. "Custom" : "hello-world",
  12. },
  13. "operation": "create"

Last modified March 18, 2021: