gpt4 book ai didi

azure - 使用 Azure KeyVault 添加 session 状态提供程序作为连接字符串

转载 作者:可可西里 更新时间:2023-11-01 11:12:25 24 4
gpt4 key购买 nike

目前我正在尝试在我的项目中添加 MS Session State Provider:https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-aspnet-session-state-provider

设置如下:

<sessionState mode="Custom" customProvider="MySessionStateStore">
<providers>
<!-- For more details check https://github.com/Azure/aspnet-redis-providers/wiki -->
<!-- Either use 'connectionString' OR 'settingsClassName' and 'settingsMethodName' OR use 'host','port','accessKey','ssl','connectionTimeoutInMilliseconds' and 'operationTimeoutInMilliseconds'. -->
<!-- 'throwOnError','retryTimeoutInMilliseconds','databaseId' and 'applicationName' can be used with both options. -->
<!--
<add name="MySessionStateStore"
host = "127.0.0.1" [String]
port = "" [number]
accessKey = "" [String]
ssl = "false" [true|false]
throwOnError = "true" [true|false]
retryTimeoutInMilliseconds = "5000" [number]
databaseId = "0" [number]
applicationName = "" [String]
connectionTimeoutInMilliseconds = "5000" [number]
operationTimeoutInMilliseconds = "1000" [number]
connectionString = "<Valid StackExchange.Redis connection string>" [String]
settingsClassName = "<Assembly qualified class name that contains settings method specified below. Which basically return 'connectionString' value>" [String]
settingsMethodName = "<Settings method should be defined in settingsClass. It should be public, static, does not take any parameters and should have a return type of 'String', which is basically 'connectionString' value.>" [String]
loggingClassName = "<Assembly qualified class name that contains logging method specified below>" [String]
loggingMethodName = "<Logging method should be defined in loggingClass. It should be public, static, does not take any parameters and should have a return type of System.IO.TextWriter.>" [String]
redisSerializerType = "<Assembly qualified class name that implements Microsoft.Web.Redis.ISerializer>" [String]
/>
-->
<add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="" accessKey="" ssl="true" />
</providers>
</sessionState>

但是,我们不想在 web.config 文件中公开带有访问 key 的连接字符串。为此,我们使用 Azure KeyVault。

有什么方法可以将 Azure KeyVault 与 session 状态提供程序结合使用?

非常感谢!

最佳答案

settingsClassName 和 settingsMethodName 设置可用于提供返回连接字符串的类和方法。您定义的此方法可以转向 KeyVault 并返回所需的连接字符串。

How to use configuration parameters of Session State Provider and Output Cache Provider

关于azure - 使用 Azure KeyVault 添加 session 状态提供程序作为连接字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55366193/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com