如何将 Azure AD 身份验证与 Redis 缓存结合使用

How to use Azure AD authentication with Redis Cache

我创建了一个配置了 Azure AD 的 MVC 应用程序。所以所有的身份验证设置都是自动的。

但我想将用户会话存储在 Azure Redis 缓存中。因为我将使用多个实例

我知道如何在 azure 中设置 redis 缓存。但是我可以从哪里在缓存中添加会话?

因为我只有这个码

 public void ConfigureAuth(IAppBuilder app)
    {
        app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

        app.UseCookieAuthentication(new CookieAuthenticationOptions());

        app.UseOpenIdConnectAuthentication(
            new OpenIdConnectAuthenticationOptions
            {
                ClientId = clientId,
                Authority = authority,
                PostLogoutRedirectUri = postLogoutRedirectUri
            });
    }

如果要将session存储在redis中:

ASP.NET Session State Provider for Azure Redis Cache

Once these steps are performed, your application is configured to use the Redis Cache Session State Provider. When you use session state in your application, it is stored in an Azure Redis Cache instance.

如果您想将 Redis 用于会话缓存以外的其他内容:

How to create a Web App with Redis Cache