Azure Blob Storage

Detailed information on the Azure Blob Store state store component

Component format

To setup Azure Blobstorage state store create a component of type state.azure.blobstorage. See this guide on how to create and apply a state store configuration.

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: <NAME>
  5. namespace: <NAMESPACE>
  6. spec:
  7. type: state.azure.blobstorage
  8. version: v1
  9. metadata:
  10. - name: accountName
  11. value: <REPLACE-WITH-ACCOUNT-NAME>
  12. - name: accountKey
  13. value: <REPLACE-WITH-ACCOUNT-KEY>
  14. - name: containerName
  15. value: <REPLACE-WITH-CONTAINER-NAME>

Warning

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

Spec metadata fields

FieldRequiredDetailsExample
accountNameYThe storage account name“mystorageaccount”.
accountKeyYPrimary or secondary storage key“key”
containerNameYThe name of the container to be used for Dapr state. The container will be created for you if it doesn’t exist“container”
ContentTypeNThe blob’s content type“text/plain”
ContentMD5NThe blob’s MD5 hash“vZGKbMRDAnMs4BIwlXaRvQ==”
ContentEncodingNThe blob’s content encoding“UTF-8”
ContentLanguageNThe blob’s content language“en-us”
ContentDispositionNThe blob’s content disposition. Conveys additional information about how to process the response payload“attachment”
CacheControlNThe blob’s cache control“no-cache”

Setup Azure Blobstorage

Follow the instructions from the Azure documentation on how to create an Azure Storage Account.

If you wish to create a container for Dapr to use, you can do so beforehand. However, Blob Storage state provider will create one for you automatically if it doesn’t exist.

In order to setup Azure Blob Storage as a state store, you will need the following properties:

  • AccountName: The storage account name. For example: mystorageaccount.
  • AccountKey: Primary or secondary storage key.
  • ContainerName: The name of the container to be used for Dapr state. The container will be created for you if it doesn’t exist.

Apply the configuration

In Kubernetes

To apply Azure Blob Storage state store to Kubernetes, use the kubectl CLI:

  1. kubectl apply -f azureblob.yaml

Running locally

To run locally, create a components dir containing the YAML file and provide the path to the dapr run command with the flag --components-path.

This state store creates a blob file in the container and puts raw state inside it.

For example, the following operation coming from service called myservice

  1. curl -X POST http://localhost:3500/v1.0/state \
  2. -H "Content-Type: application/json"
  3. -d '[
  4. {
  5. "key": "nihilus",
  6. "value": "darth"
  7. }
  8. ]'

creates the blob file in the containter with key as filename and value as the contents of file.

Concurrency

Azure Blob Storage state concurrency is achieved by using ETags according to the Azure Blob Storage documentation.

Last modified August 2, 2021 : Fix Java SDK link (#1695) (2c67fd1)