-
Notifications
You must be signed in to change notification settings - Fork 218
Set up a Redis cache in Docker
jennyf19 edited this page Mar 10, 2021
·
1 revision
First, install Docker desktop and run through the set-up wizard, and pull a redis image (docker pull redis
).
You'll need to add the following NuGet packages to your app: Microsoft.Extensions.Caching.StackExchangeRedis
and StackExchange.Redis
.
Then, in Startup.cs
add the Redis connection
services.AddStackExchangeRedisCache(options =>
{
options.Configuration = Configuration.GetConnectionString("Redis");
options.InstanceName = "RedisDemos_"; // unique to the app
});
And make sure you add .AddDistributedTokenCaches();
:
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(options =>
{
Configuration.GetSection("AzureAd").Bind(options);
})
.EnableTokenAcquisitionToCallDownstreamApi()
.AddDownstreamWebApi("TodoList", Configuration.GetSection("TodoList"))
.AddDistributedTokenCaches();
Finally, in appsettings.json
, you'll add the Redis Connection string:
"ConnectionStrings": {
"Redis": "localhost:5002" // configure w/docker
}
You're ready to start the Redis cache & start your web app and web API locally.
docker run --name my-redis -p 5002:6379 -d redis
docker exec -it my-redis sh
redis-cli
scan 0
hgetall [cachekey]
exit
exit
docker ps -a
docker stop [<numeric value of redis instance. ex. 442>]
docker rm [<numeric value of redis instance. ex. 442>]
- Home
- Why use Microsoft Identity Web?
- Web apps
- Web APIs
- Using certificates
- Minimal support for .NET FW Classic
- Logging
- Azure AD B2C limitations
- Samples
- Web apps
- Web app samples
- Web app template
- Call an API from a web app
- Managing incremental consent and conditional access
- Web app troubleshooting
- Deploy to App Services Linux containers or with proxies
- SameSite cookies
- Hybrid SPA
- Web APIs
- Web API samples
- Web API template
- Call an API from a web API
- Token Decryption
- Web API troubleshooting
- web API protected by ACLs instead of app roles
- gRPC apps
- Azure Functions
- Long running processes in web APIs
- Authorization policies
- Generic API
- Customization
- Logging
- Calling graph with specific scopes/tenant
- Multiple Authentication Schemes
- Utility classes
- Setting FIC+MSI
- Mixing web app and web API
- Deploying to Azure App Services
- Azure AD B2C issuer claim support
- Performance
- specify Microsoft Graph scopes and app-permissions
- Integrate with Azure App Services authentication
- Ajax calls and incremental consent and conditional access
- Back channel proxys
- Client capabilities