Skip to main content

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 the default container and database.
    • ShoppingCartStore: stored in the cart container and database, scoped to the ShoppingCartWorker.
  • Dedicated state stores:
    • VideoState: Uses the custom database and standard storage account, stored in the videostate container and database, scoped to the TranscriptionWorker and VideoEncodeWorker.
    • AudioState: Uses the custom database and standard storage account, stored in the audiostate container and database.
    • PremiumVideoState: Uses the premium database and premium storage account, stored in the premiumvideo container and database, scoped to the TranscriptionWorker and VideoEncodeWorker.
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

PropertyTypeRequiredAdditional requirementsDescription
namestringNo1-20 alphanumeric characters and hyphensOverride state store name (default: state store key)
typeState store typeYesState store type
kindState store kindYesState store kind
hubstringYesState store hub
secretsList of secretsNoList of secrets
environmentList of environment variablesYesList of state store configuration
scopesList of workers names (string)NoLimit access of state stores to a list of workers

State store type

State store kindDescription
DefaultStateStoreState store with database and storage container

State store kind

State store typeDescription
DedicatedA 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:

PropertyTypeRequiredDescription
namestringYesSecret name
secretReferencestringNoGlobal secret reference (recommended)
valuestringNoSecret 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:

PropertyTypeRequiredDescription
namestringYesVariable name
secretReferencestringNoReference to a state store secret
valuestringNoVariable 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:

PropertyTypeRequiredDefaultAdditional requirementsDescription
accountNamestringYes1-9 lowercase alphanumeric characters and hyphensState database and storage account name
storageTierStorage tierYesState database and storage container name
containerNamestringYes1-20 lowercase alphanumeric characters and hyphensState database and storage container name
consistencyLevelConsistency levelNoSessionDefault state store consistency level

Storage tier

Storage tierDescription
Standard_LRSStandard Storage Account, Locally-redundant storage
Standard_GRSStandard Storage Account, Geo-redundant storage
Standard_ZRSStandard Storage Account, Zone-redundant storage
Standard_GZRSStandard Storage Account, Geo-Zone-redundant storage
Premium_LRSPremium Storage Account, Locally-redundant storage
Premium_ZRSPremium Storage Account, Zone-redundant storage

Consistency level

Reflects the Cosmos DB consistency levels:

Consistency levelDescription
StrongStrong Consistency guarantees that read operations always return the value that was last written.
BoundedStalenessBounded Staleness guarantees that reads are not too out-of-date.
SessionSession 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.
ConsistentPrefixConsistentPrefix Consistency guarantees that reads will return some prefix of all writes with no gaps. All writes will be eventually be available for reads.
EventualEventual Consistency guarantees that reads will return a subset of writes. All writes will be eventually be available for reads.

Pricing

info

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:

Pricing information of Azure Cosmos DB

Pricing information of Azure Storage