I have a c# application using Dapr and docker-compose here is my docker-compose file
version: "3.7"
services:
##### Begin Infra #######
#### Postgres #####
db:
image: postgres
container_name: "dapr_prostgres"
restart: always
hostname: "postgres_server"
environment:
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "mysecretpassword"
volumes:
- ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
ports:
- 5460:5432
networks:
- calendar_my-dapr-network
##### Zipkin #####
zipkin:
container_name: "dapr_zipkin_service"
image: "openzipkin/zipkin:2.23.2"
ports:
- 9412:9411
networks:
- calendar_my-dapr-network
##### Redis #####
redis:
container_name: "dapr_redis_service"
image: "redis:6.2-alpine"
command: [ "redis-server", "/usr/local/etc/redis/redis.conf" ]
ports:
- "6380:6379"
volumes:
- ./redis.conf:/usr/local/etc/redis/redis.conf
networks:
- calendar_my-dapr-network
#### End Infra #####
##### API & DAPR Sidecar #####
calendarapi:
build:
context: .
dockerfile: ./src/APIs/Calendar.Api/Dockerfile
depends_on:
- redis
- zipkin
- db
env_file:
- .env
ports:
- "85:80"
networks:
- calendar_my-dapr-network
calendarapi_dapr:
image: "daprio/daprd:1.10.0"
command:
[
"./daprd",
"--app-id", "calendar-service",
"--app-port", "80",
"--config", "/dapr/calendar-config.yaml",
"--resources-path", "/dapr/components",
"--log-level","debug"
]
volumes:
- "./dapr:/dapr"
depends_on:
- calendarapi
network_mode: "service:calendarapi"
env_file:
- .env
networks:
calendar_my-dapr-network:
driver: bridge
when I look at the logs for the daprd container I see When I run docker compose up the logs show
time="2023-06-13T15:30:22.3665235Z" level=debug msg="found component. name: Calendar-Pub-Sub, type: pubsub.redis/v1" app_id=calendar-service instance=39b3db2d5f64 scope=dapr.runtime type=log ver=1.10.0
2023-06-13T15:30:22.366891500Z time="2023-06-13T15:30:22.3666076Z" level=debug msg="found component. name: calendar-secret-store, type: secretstores.local.file/v1" app_id=calendar-service instance=39b3db2d5f64 scope=dapr.runtime type=log ver=1.10.0
2023-06-13T15:30:22.366920200Z time="2023-06-13T15:30:22.3666275Z" level=debug msg="found component. name: calendar-statestore, type: state.redis/v1" app_id=calendar-service instance=39b3db2d5f64 scope=dapr.runtime type=log ver=1.10
but when I try to use the statestore or any other component it give me an error
public async Task SaveStateAsync(string stateStoreName,string key, T data, Dictionary<string, string>? metaData=null, CancellationToken ct=new())
{
_logger.LogDebug("Preparing to save state for {Key} {Data}",key, data);
await _daprClient.SaveStateAsync(stateStoreName,
key, data,
metadata: metaData, cancellationToken: ct);
_logger.LogDebug("Saved state for {Key} {Data}",key, data);
}
Dapr.DaprException: State operation failed: the Dapr endpoint indicated a failure. See InnerException for details. ---> Grpc.Core.RpcException: Status(StatusCode="FailedPrecondition", Detail="state store is not configured") at Dapr.Client.DaprClientGrpc.MakeSaveStateCallAsync[TValue](String storeName, String key, TValue value, String etag, StateOptions stateOptions, IReadOnlyDictionary2 metadata, CancellationToken cancellationToken) --- End of inner exception stack trace ---