redis-vl-dotnet
Getting Started
This section is the canonical entry point for installation, local Redis setup, connection environment variables, and the first end-to-end workflow.
Prerequisites
The current local development flow assumes:
-
.NET 9 SDK
-
Redis Stack or another Redis deployment with RediSearch enabled
-
RedisJSON support for JSON-backed examples and document workflows
-
Docker Desktop or another Docker-compatible runtime when you want the repository-managed local Redis instance
-
A reachable Redis connection string such as
localhost:6379
Default local setup
Start Redis Stack locally from the repository root:
docker compose -f docker-compose.integration.yml up -d redis-stack
export REDIS_VL_REDIS_URL=localhost:6379
Install and validate the docs plus example toolchain from the repository root:
dotnet --version
npm install
npm run docs:validate
npm run examples:build
Run the first end-to-end example:
dotnet run --project examples/JsonStorageExample/JsonStorageExample.csproj
Connection environment variables
The examples and tests use environment variables so the same commands work across local, cluster, and Sentinel deployments.
| Variable | Required when | Purpose |
|---|---|---|
|
Direct connection flow |
Standalone Redis endpoint. The examples fall back to |
|
Cluster flow |
Comma-delimited Redis cluster seed nodes such as |
|
Sentinel flow |
Comma-delimited Redis Sentinel nodes such as |
|
Sentinel flow |
Sentinel primary service name, for example |
|
Authenticated cluster or Sentinel flow |
Redis username forwarded through the connection factory helpers. |
|
Authenticated cluster or Sentinel flow |
Redis password forwarded through the connection factory helpers. |
|
TLS-enabled cluster or Sentinel flow |
Set to |
Copy-paste connection setup
Use only one topology block at a time.
Direct local Redis
docker compose -f docker-compose.integration.yml up -d redis-stack
export REDIS_VL_REDIS_URL=localhost:6379
dotnet run --project examples/JsonStorageExample/JsonStorageExample.csproj
Redis cluster
unset REDIS_VL_REDIS_URL
export REDIS_VL_REDIS_CLUSTER_NODES=127.0.0.1:7000,127.0.0.1:7001,127.0.0.1:7002
export REDIS_VL_REDIS_USER=default
export REDIS_VL_REDIS_PASSWORD=secret
export REDIS_VL_REDIS_SSL=false
dotnet run --project examples/JsonStorageExample/JsonStorageExample.csproj
Redis Sentinel
unset REDIS_VL_REDIS_URL
export REDIS_VL_REDIS_SENTINEL_NODES=127.0.0.1:26379,127.0.0.1:26380,127.0.0.1:26381
export REDIS_VL_REDIS_SENTINEL_SERVICE_NAME=mymaster
export REDIS_VL_REDIS_USER=default
export REDIS_VL_REDIS_PASSWORD=secret
export REDIS_VL_REDIS_SSL=false
dotnet run --project examples/JsonStorageExample/JsonStorageExample.csproj
First workflow
The minimal library flow is:
-
Add the library to an app
-
Connect to Redis
-
Define a schema
-
Create an index
-
Load documents
-
Fetch and query documents
-
Clear or drop the index when finished
The current canonical walkthrough for that sequence still starts from the JSON example and the runnable examples catalog:
-
Examples maps the main feature areas to concrete sample projects
-
/examples/JsonStorageExampledemonstrates schema creation, document loading, fetch, filter search, text search, aggregations, count, clear, and drop flows
Connection topologies
Use RedisConnectionFactory when you need StackExchange.Redis ConfigurationOptions helpers for more than a direct endpoint:
-
cluster discovery through
ConnectClusterAsync(…) -
Sentinel discovery through
ConnectSentinelPrimaryAsync(…) -
parsed option creation through
CreateClusterOptions(…)andCreateSentinelOptions(…)
These helpers normalize seed-node lists, reject unsupported configuration early, and keep the rest of the library on the same IDatabase-based APIs.
Provider environment variables
Provider-backed examples add service credentials on top of the Redis connection variables:
| Variable | Used by |
|---|---|
|
|
|
Optional override for the OpenAI example embedding model. Defaults to |
|
Optional override for the OpenAI example embedding size. Defaults to |
|
|
|
|
If those credentials are missing, the provider-backed examples and matching integration tests fail fast with an explicit environment-variable message instead of attempting a partially configured request.
Related sections
-
Core Features for schema, index, document, and query coverage
-
Examples for runnable sample projects
-
Testing for local validation commands and Redis-backed test setup