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

标签 c# azure azure-active-directory azure-redis-cache

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

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

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

因为我只有这个代码

 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 用于 session 缓存之外的其他内容:

How to create a Web App with Redis Cache

关于c# - 如何将 Azure AD 身份验证与 Redis 缓存结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47441948/

相关文章:

python - Docker 容器中的 Azure 函数 Python 模型 2

azure - 对 Azure 存储的只写访问(不可读取、不可列表、不可删除)

azure - 如何使用 Azure 认知搜索的知识挖掘结果并填充聊天机器人的知识库?

azure - 如何获取 Azure 应用程序注册的子集

c# - Math.Ceiling 奇怪的行为

c# - 在C#中获取一个国家的大陆

c# - 使用正则表达式防止 mvc 文本框中的 html 标签条目

azure - Azure 云 shell 中缺少 New-AzureADPolicy

c# - AuthenticationBuilder 不包含 AddAzureAd 的定义

c# - 无法安装软件包 'Stripe.net 39.27.0' 。您正在尝试将此软件包安装到目标为 '