To setup SQL Server state store create a component of type state.sqlserver
. 请参阅本指南,了解如何创建和应用状态存储配置。
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
namespace: <NAMESPACE>
spec:
type: state.sqlserver
version: v1
metadata:
- name: connectionString
value: <REPLACE-WITH-CONNECTION-STRING> # Required.
- name: tableName
value: <REPLACE-WITH-TABLE-NAME> # Required.
- name: keyType
value: <REPLACE-WITH-KEY-TYPE> # Optional. defaults to "string"
- name: keyLength
value: <KEY-LENGTH> # Optional. defaults to 200. Yo be used with "string" keyType
- name: schema
value: <SCHEMA> # Optional. defaults to "dbo"
- name: indexedProperties
value: <INDEXED-PROPERTIES> # Optional. List of IndexedProperties.
If you wish to use Redis as an actor state store, append the following to the yaml.
- name: actorStateStore
value: "true"
字段 | 必填 | 详情 | Example |
---|---|---|---|
connectionString | Y | The connection string used to connect | "Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;Password=myPassword;" |
tableName | Y | The name of the table to use. Alpha-numeric with underscores | "table_name" |
keyType | N | The type of key used. Defaults to "string" | "string" |
keyLength | N | The max length of key. Used along with "string" keytype. 默认值为 "200" | "200" |
schema | N | The schema to use. Defaults to "dbo" | "dapr" ,"dbo" |
indexedProperties | N | List of IndexedProperties. | "[{"ColumnName": "column", "Property": "property", "Type": "type"}]" |
actorStateStore | N | Indicates that Dapr should configure this component for the actor state store (more information). | “true” |
Follow the instructions from the Azure documentation on how to create a SQL database. The database must be created before Dapr consumes it. The database must be created before Dapr consumes it. The database must be created before Dapr consumes it.
Note: SQL Server state store also supports SQL Server running on VMs.
In order to setup SQL Server as a state store, you need the following properties:
When connecting with a dedicated user (not sa
), these authorizations are required for the user - even when the user is owner of the desired database schema:
CREATE TABLE
CREATE TYPE