The documentation you are viewing is for Dapr v1.0 which is an older version of Dapr. For up-to-date documentation, see the latest version.


Detailed information on the MongoDB state store component

Component format

To setup MongoDB state store create a component of type state.mongodb. See this guide on how to create and apply a state store configuration.

kind: Component
  name: <NAME>
  namespace: <NAMESPACE>
  type: state.mongodb
  version: v1
  - name: host
    value: <REPLACE-WITH-HOST> # Required. Example: "mongo-mongodb.default.svc.cluster.local:27017"
  - name: username
    value: <REPLACE-WITH-USERNAME> # Optional. Example: "admin"
  - name: password
    value: <REPLACE-WITH-PASSWORD> # Optional.
  - name: databaseName
    value: <REPLACE-WITH-DATABASE-NAME> # Optional. default: "daprStore"
  - name: collectionName
    value: <REPLACE-WITH-COLLECTION-NAME> # Optional. default: "daprCollection"
  - name: writeconcern
    value: <REPLACE-WITH-WRITE-CONCERN> # Optional.
  - name: readconcern
    value: <REPLACE-WITH-READ-CONCERN> # Optional.
  - name: operationTimeout
    value: <REPLACE-WITH-OPERATION-TIMEOUT> # Optional. default: "5s"

If you wish to use MongoDB as an actor store, append the following to the yaml.

  - name: actorStateStore
    value: "true"

Spec metadata fields

Field Required Details Example
host Y The host to connect to "mongo-mongodb.default.svc.cluster.local:27017"
username N The username of the user to connect with "admin"
password N The password of the user "password"
databaseName N The name of the database to use. Defaults to "daprStore" "daprStore"
collectionName N The name of the collection to use. Defaults to "daprCollection" "daprCollection"
writeconcern N The write concern to use "majority"
readconcern N The read concern to use "majority", "local","available", "linearizable", "snapshot"
operationTimeout N The timeout for the operation. Defautls to "5s" "5s"

Setup MongoDB

You can run MongoDB locally using Docker:

docker run --name some-mongo -d mongo

You can then interact with the server using localhost:27017.

The easiest way to install MongoDB on Kubernetes is by using the Helm chart:

helm install mongo stable/mongodb

This installs MongoDB into the default namespace. To interact with MongoDB, find the service with: kubectl get svc mongo-mongodb.

For example, if installing using the example above, the MongoDB host address would be:


Follow the on-screen instructions to get the root password for MongoDB. The username is admin by default.

Last modified July 8, 2022: update nav bar for v1.0 (#2634) (7fd6223)