简体   繁体   中英

How to use Azure AD authentication with Redis Cache

I have created an MVC application with Azure AD configured. So all the Authentication setup is automated.

But I want to store users session in Azure Redis Cache. As I will be using multiple instances

I know how to setup redis cache in azure. But from where I can add Session in cache ?

As I have only got this code

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

        app.UseCookieAuthentication(new CookieAuthenticationOptions());

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

If you want to store the session in 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.

If you want to use redis for stuff other than session cache:

How to create a Web App with Redis Cache

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM