Dapr State Store resource

Learn how to use a Dapr State Store resource in Radius

Overview

A Applications.Dapr/stateStores resource represents a Dapr state store topic.

This resource will automatically create and deploy the Dapr component spec for the state store.

Resource format


resource statestore 'Applications.Dapr/stateStores@2023-10-01-preview' = {
  name: 'statestore'
  properties: {
    environment: environment
    application: application
    recipe: {
      // Name a specific Recipe to use
      name: 'azure-redis'
      // Optionally set recipe parameters if needed (specific to the Recipe)
      parameters: {
        // ....
      }
    }
  }
}

resource statestore 'Applications.Dapr/stateStores@2023-10-01-preview' = {
  name: 'statestore'
  properties: {
    environment: environment
    application: application
    resourceProvisioning: 'manual'
    resources: [
      { id: account.id }
      { id: account::tableServices::table.id }
    ]
    metadata: {
      accountName: {
        value: account.name
      }
      accountKey: {
        value: account.listKeys().keys[0].value
      }
      tableName: {
        value: account::tableServices::table.name
      }
    }
    type: 'state.azure.tablestorage'
    version: 'v1'
  }
}

Top-level

KeyRequiredDescriptionExample
nameyThe name of the resource. Names must contain at most 63 characters, contain only lowercase alphanumeric characters, ‘-’, or ‘.’, start with an alphanumeric character, and end with an alphanumeric character.my-statestore
locationyThe location of your resource. See common values for more information.global
propertiesyProperties of the resource.See below

Properties

KeyRequiredDescriptionExample
applicationnThe ID of the application resource this resource belongs to.app.id
environmentyThe ID of the environment resource this resource belongs to.env.id
resourceProvisioningnSpecifies how the underlying service/resource is provisioned and managed. Options are to provision automatically via ‘recipe’ or provision manually via ‘manual’. Selection determines which set of fields to additionally require. Defaults to ‘recipe’.manual
recipenConfiguration for the Recipe which will deploy the backing infrastructure.See below
resourcesnAn array of IDs of the underlying resources.See below
typenThe Dapr component type. Used when resourceProvisioning is set to manual.state.couchbase
metadatanMetadata for the Dapr component. Schema must match Dapr component. Used when resourceProvisioning is set to manual.{ couchbaseURL: {value: 'https://*****' }
versionnThe version of the Dapr component. See Dapr components for available versions. Used when resourceProvisioning is set to manual.v1
componentNamen(read-only) The name of the Dapr component that is generated and applied to the underlying system. Used by the Dapr SDKs or APIs to access the Dapr component.mystatestore

Recipe

PropertyRequiredDescriptionExample(s)
namenSpecifies the name of the Recipe that should be deployed. If not set, the name defaults to default.name: 'azure-prod'
parametersnAn object that contains a list of parameters to set on the Recipe.{ version: 'v1' }

Resources

PropertyRequiredDescriptionExample(s)
idnResource ID of the supporting resource.account::tableService::table.id

Resource provisioning

Provision with a Recipe

Recipes automate infrastructure provisioning using approved templates. When no Recipe configuration is set Radius will use the Recipe registered as the default in the environment for the given resource. Otherwise, a Recipe name and parameters can optionally be set.

Provision manually

If you want to manually manage your infrastructure provisioning outside of Recipes, you can set resourceProvisioning to 'manual' and provide all necessary parameters and values and values that enable Radius to deploy or connect to the desired infrastructure.

Environment variables for connections

Other Radius resources, such as containers, may connect to a Dapr state store resource via connections. When a connection to Dapr state store named, for example, myconnection is declared, Radius injects values into environment variables that are then used to access the connected Dapr state store resource:

Environment variableExample(s)
CONNECTION_MYCONNECTION_COMPONENTNAMEmystatestore