Azure Table Storage

Detailed information on the Azure Table Storage state store component

Create an Azure Storage account

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

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

In order to setup Azure Table 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.

  • TableName: The name of the table to be used for Dapr state. The table will be created for you if it doesn’t exist.

Create a Dapr component

The next step is to create a Dapr component for Azure Table Storage.

Create the following YAML file named azuretable.yaml:

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: <NAME>
  5. namespace: <NAMESPACE>
  6. spec:
  7. type: state.azure.tablestorage
  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: tableName
  15. value: <REPLACE-WITH-TABLE-NAME>

Warning

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

Example

The following example uses the Kubernetes secret store to retrieve the secrets:

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: <NAME>
  5. namespace: <NAMESPACE>
  6. spec:
  7. type: state.azure.tablestorage
  8. version: v1
  9. metadata:
  10. - name: accountName
  11. value: <REPLACE-WITH-ACCOUNT-NAME>
  12. - name: accountKey
  13. secretKeyRef:
  14. name: <KUBERNETES-SECRET-NAME>
  15. key: <KUBERNETES-SECRET-KEY>
  16. - name: tableName
  17. value: <REPLACE-WITH-TABLE-NAME>

Apply the configuration

In Kubernetes

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

  1. kubectl apply -f azuretable.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.

Partitioning

The Azure Table Storage state store will use the key property provided in the requests to the Dapr API to determine the row key. Service Name is used for partition key. This provides best performance, as each service type will store state in it’s own table partition.

This state store creates a column called Value in the table storage 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. ]'

will create the following record in a table:

PartitionKeyRowKeyValue
myservicenihilusdarth

Concurrency

Azure Table Storage state concurrency is achieved by using ETags according to the official documenation.

Last modified February 16, 2021: Merge pull request #1235 from dapr/update-v0.11 (b4e9fbb)