Azure Blob Storage

To setup the Azure Blob Storage state store create a component of type . See this guide on how to create and apply a state store configuration.

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

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, the 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 account 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.
  1. To get started with using Azure AD for authenticating the Blob Storage state store component, make sure you’ve created an Azure AD application and a Service Principal as explained in the document.
    Once done, set a variable with the ID of the Service Principal that you created:
  1. Using RBAC, assign a role to our Service Principal so it can access data inside the Storage Account.
    In this case, you are assigning the “Storage blob Data Contributor” role, which has broad access; other more restrictive roles can be used as well, depending on your application.
  1. RG_ID=$(az group show --resource-group ${RG_NAME} | jq -r ".id")
  2. az role assignment create \
  3. --assignee "${SERVICE_PRINCIPAL_ID}" \
  4. --role "Storage blob Data Contributor" \
  5. --scope "${RG_ID}/providers/Microsoft.Storage/storageAccounts/${STORAGE_ACCOUNT_NAME}"

When authenticating your component using Azure AD, the accountKey field is not required. Instead, please specify the required credentials in the component’s metadata (if any) according to the Authenticating to Azure document.

For example:

Apply the configuration

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

  1. kubectl apply -f azureblob.yaml

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:

This creates the blob file in the container with key as filename and as the contents of file.

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

Last modified January 18, 2023: