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:
create
: Create blobget
:
To perform a create blob operation, invoke the Azure Blob Storage binding with a POST
method and the following JSON body:
{
"operation": "create",
"data": "YOUR_CONTENT"
}
Examples
Save text to a random generated UUID blob
On Windows, utilize cmd prompt (PowerShell has different escaping mechanism)
curl -d "{ \"operation\": \"create\", \"data\": \"Hello World\" }" http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
curl -d '{ "operation": "create", "data": "Hello World" }' \
http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
Save text to a specific blob
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:
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
namespace: <NAMESPACE>
spec:
type: bindings.azure.blobstorage
version: v1
metadata:
- name: storageAccount
value: myStorageAccountName
- name: storageAccessKey
value: ***********
- name: container
value: container1
- name: decodeBase64
value: "true"
Then you can upload it as you would normally:
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:
{
"blobURL": "https://<your account name>. blob.core.windows.net/<your container name>/<filename>"
Get blob
"operation": "get",
"metadata": {
"blobName": "myblob"
}
}
Example
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:
{
"data": "file content",
"metadata": {
"blobName" : "filename.txt",
"ContentType" : "text/plain",
"ContentMD5" : "vZGKbMRDAnMs4BIwlXaRvQ==",
"ContentEncoding" : "UTF-8",
"ContentLanguage" : "en-us",
"ContentDisposition" : "attachment",
"CacheControl" : "no-cache",
"Custom" : "hello-world",
},
"operation": "create"
Last modified March 18, 2021: