# Azure Table Storage

Type: `state.azure.tablestorage`

Status: stable

Reference: https://docs.dapr.io/reference/components-reference/supported-state-stores/setup-azure-tablestorage/

## Example

```
apiVersion: cra.diagrid.io/v1beta1
kind: Component
metadata:
  name: <name>
spec:
  type: state.azure.tablestorage
  version: v1
  metadata:
    # The key to authenticate to the Storage Account or Cosmos DB Table API.
    - name: accountKey
      value: "my-secret-key"
    # The storage account name.
    - name: accountName
      value: "mystorageaccount"
    # The name of the table to be used for Dapr state. The table will be created for you if it doesn't exist.
    - name: tableName
      value: "table"
    # If enabled, connects to Cosmos DB Table API instead of Azure Tables (Storage Accounts). (Optional)
    #- name: cosmosDbMode
    #  value: "false"
    # Prefix added to keys in the state store. (Optional)
    #- name: keyPrefix
    #  value: "appid"
    # The full storage service endpoint URL. Useful for Azure environments other than public cloud. (Optional)
    #- name: serviceURL
    #  value: "https://mystorageaccount.table.core.windows.net/"
    # Skips the check for and, if necessary, creation of the specified storage table. This is useful when using active directory authentication with minimal privileges. (Optional)
    #- name: skipCreateTable
    #  value: "false"

```

## Authentication profiles

Available authentication profiles:

- Account Key

- Azure AD: Client credentials

- Azure AD: Client certificate

### Account Key

Authenticate using a pre-shared "account key".

#### `accountKey`

**Required** - The key to authenticate to the Storage Account or Cosmos DB Table API.

Example value: `my-secret-key`

### Azure AD: Client credentials

Authenticate using Azure AD with client credentials, also known as "service principals".

#### `azureClientId`

**Required** - Client ID (application ID)

Example value: `c7dd251f-811f-4ba2-a905-acd4d3f8f08b`

#### `azureClientSecret`

**Required** - Client secret (application password)

Example value: `Ecy3XG7zVZK3/vl/a2NSB+a1zXLa8RnMum/IgD0E`

#### `azureTenantId`

**Required** - ID of the Azure AD tenant

Example value: `cd4b2887-304c-47e1-b4d5-65447fdd542a`

#### `azureEnvironment`

Optional name for the Azure environment if using a different Azure cloud

Default value: `AzurePublicCloud`

Example value: `AzurePublicCloud`

Allowed values:

- AzurePublicCloud

- AzureChinaCloud

- AzureUSGovernmentCloud

### Azure AD: Client certificate

Authenticate using Azure AD with a client certificate. "azureCertificate" is required.

#### `azureClientId`

**Required** - Client ID (application ID)

Example value: `c7dd251f-811f-4ba2-a905-acd4d3f8f08b`

#### `azureTenantId`

**Required** - ID of the Azure AD tenant

Example value: `cd4b2887-304c-47e1-b4d5-65447fdd542a`

#### `azureCertificate`

Certificate and private key (in either a PEM file containing both the certificate and key, or in PFX/PKCS#12 format)

Example value:

```
-----BEGIN PRIVATE KEY-----\n MIIEvgI... \n -----END PRIVATE KEY-----
\n -----BEGIN CERTIFICATE----- \n MIICoTC... \n -----END CERTIFICATE----- \n

```

#### `azureCertificatePassword`

Password for the certificate if encrypted.

Example value: `password`

#### `azureEnvironment`

Optional name for the Azure environment if using a different Azure cloud

Default value: `AzurePublicCloud`

Example value: `AzurePublicCloud`

Allowed values:

- AzurePublicCloud

- AzureChinaCloud

- AzureUSGovernmentCloud

## Metadata

### `accountName` (string)

**Required** - The storage account name.

Example value: `mystorageaccount`

### `tableName` (string)

**Required** - The name of the table to be used for Dapr state. The table will be created for you if it doesn't exist.

Example value: `table`

### `cosmosDbMode` (bool)

If enabled, connects to Cosmos DB Table API instead of Azure Tables (Storage Accounts).

Default value: `false`

Example value: `false`

### `keyPrefix` (string)

Prefix added to keys in the state store.

Default value: `appid`

Example value: `appid`

Allowed values:

- appid

- name

- none

Documentation: https://docs.dapr.io/developing-applications/building-blocks/state-management/howto-share-state/

### `serviceURL` (string)

The full storage service endpoint URL. Useful for Azure environments other than public cloud.

Example value: `https://mystorageaccount.table.core.windows.net/`

### `skipCreateTable` (bool)

Skips the check for and, if necessary, creation of the specified storage table. This is useful when using active directory authentication with minimal privileges.

Default value: `false`

Example value: `true`
