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
:delete
: Delete bloblist
:
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
curl -d "{ \"operation\": \"create\", \"data\": \"Hello World\", \"metadata\": { \"blobName\": \"my-test-file.txt\" } }" \
http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
curl -d '{ "operation": "create", "data": "Hello World", "metadata": { "blobName": "my-test-file.txt" } }' \
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
metadata:
value: myStorageAccountName
- name: storageAccessKey
value: ***********
- name: container
value: container1
- name: decodeBase64
value: true
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>"
}
To perform a get blob operation, invoke the Azure Blob Storage binding with a POST
method and the following JSON body:
{
"operation": "get",
"metadata": {
"blobName": "myblob",
"includeMetadata": "true"
}
}
The metadata parameters are:
blobName
- the name of the blobincludeMetadata
- (optional) defines if the user defined metadata should be returned or not, defaults to: false
Example
curl -d '{ \"operation\": \"get\", \"metadata\": { \"blobName\": \"myblob\" }}' http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
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. If enabled, the user defined metadata will be returned as HTTP headers in the form:
Metadata.key1: value1
Metadata.key2: value2
To perform a delete blob operation, invoke the Azure Blob Storage binding with a POST
method and the following JSON body:
{
"operation": "delete",
"metadata": {
"blobName": "myblob"
}
}
The metadata parameters are:
blobName
- the name of the blobdeleteSnapshots
- (optional) required if the blob has associated snapshots. Specify one of the following two options:- include: Delete the base blob and all of its snapshots
- only: Delete only the blob’s snapshots and not the blob itself
Examples
Delete blob
curl -d '{ "operation": "delete", "metadata": { "blobName": "myblob" }}' \
http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
Delete blob snapshots only
curl -d '{ \"operation\": \"delete\", \"metadata\": { \"blobName\": \"myblob\", \"deleteSnapshots\": \"only\" }}' http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
curl -d '{ "operation": "delete", "metadata": { "blobName": "myblob", "deleteSnapshots": "only" }}' \
Delete blob including snapshots
curl -d '{ \"operation\": \"delete\", \"metadata\": { \"blobName\": \"myblob\", \"deleteSnapshots\": \"include\" }}' http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
curl -d '{ "operation": "delete", "metadata": { "blobName": "myblob", "deleteSnapshots": "include" }}' \
http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
Response
To perform a list blobs operation, invoke the Azure Blob Storage binding with a POST
method and the following JSON body:
{
"operation": "list",
"data": {
"maxResults": 10,
"prefix": "file",
"marker": "2!108!MDAwMDM1IWZpbGUtMDgtMDctMjAyMS0wOS0zOC01NS03NzgtMjEudHh0ITAwMDAyOCE5OTk5LTEyLTMxVDIzOjU5OjU5Ljk5OTk5OTlaIQ--",
"include": {
"snapshots": false,
"metadata": true,
"uncommittedBlobs": false,
"copy": false,
"deleted": false
}
}
}
The data parameters are:
maxResults
- (optional) specifies the maximum number of blobs to return, including all BlobPrefix elements. If the request does not specify maxresults the server will return up to 5,000 items.prefix
- (optional) filters the results to return only blobs whose names begin with the specified prefix.marker
- (optional) a string value that identifies the portion of the list to be returned with the next list operation. The operation returns a marker value within the response body if the list returned was not complete. The marker value may then be used in a subsequent call to request the next set of list items.include
- (optional) Specifies one or more datasets to include in the response:- snapshots: Specifies that snapshots should be included in the enumeration. Snapshots are listed from oldest to newest in the response. Defaults to: false
- metadata: Specifies that blob metadata be returned in the response. Defaults to: false
- uncommittedBlobs: Specifies that blobs for which blocks have been uploaded, but which have not been committed using Put Block List, be included in the response. Defaults to: false
- copy: Version 2012-02-12 and newer. Specifies that metadata related to any current or previous Copy Blob operation should be included in the response. Defaults to: false
- deleted: Version 2017-07-29 and newer. Specifies that soft deleted blobs should be included in the response. Defaults to: false
Response
The response body contains the list of found blocks as also the following HTTP headers:
Metadata.marker: 2!108!MDAwMDM1IWZpbGUtMDgtMDctMjAyMS0wOS0zOC0zNC04NjctMTEudHh0ITAwMDAyOCE5OTk5LTEyLTMxVDIzOjU5OjU5Ljk5OTk5OTlaIQ--
Metadata.number: 10
marker
- the next marker which can be used in a subsequent call to request the next set of list items. See the marker description on the data property of the binding input.number
- the number of found blobs
The list of blobs will be returned as JSON array in the following form:
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"
- Basic schema for a Dapr component
- How-To: Trigger application with input binding
- Bindings API reference