State store configuration
In this section, you will learn how to set up state stores in Taskurai.
State stores are defined in the Taskurai configuration (YAML) and are deployed and managed using the Taskurai CLI.
State store deployment configuration
A state store is deployed using a configuration section in the solution yaml.
Reference state store configuration
This is a reference state store configuration sample:
- Internal state stores:
DefaultStateStore: stored in thedefaultcontainer and database.ShoppingCartStore: stored in thecartcontainer and database, scoped to theShoppingCartWorker.
- Dedicated state stores:
VideoState: Uses thecustomdatabase and standard storage account, stored in thevideostatecontainer and database, scoped to theTranscriptionWorkerandVideoEncodeWorker.AudioState: Uses thecustomdatabase and standard storage account, stored in theaudiostatecontainer and database.PremiumVideoState: Uses thepremiumdatabase and premium storage account, stored in thepremiumvideocontainer and database, scoped to theTranscriptionWorkerandVideoEncodeWorker.
stateStores:
DefaultStateStore:
type: DefaultStateStore
kind: Dedicated
hub: DefaultHub
environment:
- name: containerName
value: default
ShoppingCartStore:
type: DefaultStateStore
kind: Dedicated
hub: DefaultHub
environment:
- name: containerName
value: cart
scopes:
- ShoppingCartWorker
VideoState:
type: DefaultStateStore
kind: Dedicated
hub: DefaultHub
environment:
- name: accountName
value: custom
- name: storageTier
value: Standard_LRS
- name: containerName
value: videostate
scopes:
- TranscriptionWorker
- VideoEncodeWorker
AudioState:
type: DefaultStateStore
kind: Dedicated
hub: DefaultHub
environment:
- name: accountName
value: custom
- name: storageTier
value: Standard_LRS
- name: containerName
value: audiostate
PremiumVideoState:
type: DefaultStateStore
kind: Dedicated
hub: DefaultHub
environment:
- name: accountName
value: premium
- name: storageTier
value: Premium_ZRS
- name: containerName
value: premiumvideo
scopes:
- TranscriptionWorker
- VideoEncodeWorker
State store configuration
| Property | Type | Required | Additional requirements | Description |
|---|---|---|---|---|
name | string | No | 1-20 alphanumeric characters and hyphens | Override state store name (default: state store key) |
type | State store type | Yes | State store type | |
kind | State store kind | Yes | State store kind | |
hub | string | Yes | State store hub | |
secrets | List of secrets | No | List of secrets | |
environment | List of environment variables | Yes | List of state store configuration | |
scopes | List of workers names (string) | No | Limit access of state stores to a list of workers |
State store type
| State store kind | Description |
|---|---|
DefaultStateStore | State store with database and storage container |
State store kind
| State store type | Description |
|---|---|
Dedicated | A Dedicated state store can be configured to either share or have dedicated database and storage accounts, providing more throughput and avoiding noisy neighbor issues. You can choose between a standard or premium storage account, depending on your needs, such as storing large files with optimal performance and low latency. |
Secret configuration
Each state store can contain secrets to be used in environment variables.
Secret properties:
| Property | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Secret name |
secretReference | string | No | Global secret reference (recommended) |
value | string | No | Secret value (not recommended) |
While it is technically possible to define a secret value directly in the state store configuration, it is highly recommended to use globally defined secrets in Taskurai and reference them in the state store.
options:
...
secrets:
- myglobalcontainerregistrypassword
- myglobalsecret
workers:
TestWorker:
container:
...
passwordSecretReference: containerregistrypassword
...
secrets:
- name: containerregistrypassword
secretReference: myglobalcontainerregistrypassword
- name: mycontainersecret
secretReference: myglobalsecret
environment:
- name: ENV_WITH_SECRET
secretReference: mycontainersecret
- name: ENV_WITH_VALUE
value: myvalue
...
Notice that the global Taskurai secret can only be referenced in the state store secret configuration. To use secrets within the state store itself, the local secrets defined in the state store should be used.
Environment configuration
Environment variables can be set to be used in containers.
Environment variable properties:
| Property | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Variable name |
secretReference | string | No | Reference to a state store secret |
value | string | No | Variable value |
An environment variable can either be a plain text value or can reference a state store secret.
options:
...
secrets:
- myglobalcontainerregistrypassword
- myglobalsecret
stateStores:
ShoppingCartStore:
...
secrets:
...
- name: mycontainersecret
secretReference: myglobalsecret
environment:
- name: ENV_WITH_SECRET
secretReference: mycontainersecret
- name: ENV_WITH_VALUE
value: myvalue
...
Dedicated state stores
Dedicated state stores can be configured to either share or have dedicated database and storage accounts, providing more throughput and avoiding noisy neighbor issues.
You can choose between a standard or premium storage account, depending on your needs, such as storing large files with optimal performance and lower latency.
Depending on the Taskurai Plan, it is possible to define multiple Dedicated state stores, either sharing the same resources or being set up with dedicated resources.
Dedicated state store configuration
State stores are configured using the following environment variables:
| Property | Type | Required | Default | Additional requirements | Description |
|---|---|---|---|---|---|
accountName | string | Yes | 1-9 lowercase alphanumeric characters and hyphens | State database and storage account name | |
storageTier | Storage tier | Yes | State database and storage container name | ||
containerName | string | Yes | 1-20 lowercase alphanumeric characters and hyphens | State database and storage container name | |
consistencyLevel | Consistency level | No | Session | Default state store consistency level |
Storage tier
| Storage tier | Description |
|---|---|
Standard_LRS | Standard Storage Account, Locally-redundant storage |
Standard_GRS | Standard Storage Account, Geo-redundant storage |
Standard_ZRS | Standard Storage Account, Zone-redundant storage |
Standard_GZRS | Standard Storage Account, Geo-Zone-redundant storage |
Premium_LRS | Premium Storage Account, Locally-redundant storage |
Premium_ZRS | Premium Storage Account, Zone-redundant storage |
Consistency level
Reflects the Cosmos DB consistency levels:
| Consistency level | Description |
|---|---|
Strong | Strong Consistency guarantees that read operations always return the value that was last written. |
BoundedStaleness | Bounded Staleness guarantees that reads are not too out-of-date. |
Session | Session Consistency guarantees monotonic reads (you never read old data, then new, then old again), monotonic writes (writes are ordered) and read your writes (your writes are immediately visible to your reads) within any single session. |
ConsistentPrefix | ConsistentPrefix Consistency guarantees that reads will return some prefix of all writes with no gaps. All writes will be eventually be available for reads. |
Eventual | Eventual Consistency guarantees that reads will return a subset of writes. All writes will be eventually be available for reads. |
Pricing
Taskurai deploys database and storage resources in a Taskurai Hub, installed in your Azure subscription, to implement states stores. RU-based billing and additional Azure resource costs apply.
For more information: