Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync 2.0.0

前缀已保留
dotnet add package Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync --version 2.0.0                
NuGet\Install-Package Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync -Version 2.0.0                
此命令旨在在 Visual Studio 的 Package Manager Console 中使用,因为它使用了 NuGet 模块的 Install-Package 版本。
<PackageReference Include="Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync" Version="2.0.0" />                
对于支持 PackageReference 的项目,将此 XML 节点复制到项目文件中引用该包。
paket add Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync --version 2.0.0                
#r "nuget: Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync, 2.0.0"                
#r 指令可在 F# Interactive 和 Polyglot Notebooks 中使用。将此复制到交互工具或脚本的源代码中引用包。
// Install Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync as a Cake Addin
#addin nuget:?package=Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync&version=2.0.0

// Install Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync as a Cake Tool
#tool nuget:?package=Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync&version=2.0.0                

Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync

在 .Net 4.6.2 中,asp.net 允许开发者插入 SessionState 模块的异步版本,该版本非常适合非内存 SessionState 数据存储。此 SessionState 提供者使用 SQL Server 作为数据存储,并利用异步数据库操作提供更好的可伸缩性。

在您可以指定此新异步提供者之前,您需要按此处描述设置新的异步 SessionStateModule。

然后,如此注册您的新提供者

  <sessionState cookieless="false" regenerateExpiredSessionId="true" mode="Custom" customProvider="CosmosDBSessionStateProviderAsync">
    <providers>
      <add name="CosmosDBSessionStateProviderAsync" cosmosDBEndPointSettingKey="cosmosDBEndPointSetting" cosmosDBAuthKeySettingKey="cosmosDBAuthKeySetting"
          databaseId="[DataBaseId]" collectionId="[CollectionId]" offerThroughput="5000" connectionMode="Direct" requestTimeout="5" skipKeepAliveWhenUnused="false"
          maxConnectionLimit="50" maxRetryAttemptsOnThrottledRequests="10" maxRetryWaitTimeInSeconds="10" consistencyLevel="Session" preferredLocations=""
          type="Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync, Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </providers>
  </sessionState>

注意 对于最佳可伸缩性,建议使用“通配符”分区配置 CosmosDB 提供者。出于更新兼容性的目的,这并非默认设置。请阅读下面的 partitionKeyPathpartitionNumUsedByProvider

Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync 设置

  1. cosmosDBEndPointSettingKey - 指向 CosmosDB 端点的 appsetting 键名称

  2. cosmosDBAuthKeySettingKey - 指向 CosmosDB 认证键的 appsetting 键名称

  3. offerThroughput - Azure DocumentDB 数据库服务中指定集合的吞吐量吞吐量配置,以请求/单位来衡量。如果提供的集合不存在,服务商会创建一个使用此 offerThroughput 的集合。如果设置为 "0",则集合将使用数据库的默认吞吐量。

  4. connectionMode - 直接 | 网关

  5. requestTimeout - 连接到 Azure DocumentDB 数据库服务时的请求超时时间(秒)。

  6. skipKeepAliveWhenUnused - 此设置将跳过对未读取或写入会话状态请求更新过期时间的调用。默认为 "false",以保持与先前行为的兼容性。但某些应用程序(如 MVC)可能会有大量请求被处理,而这些请求甚至从未查看会话状态,因此可以受益于将此设置为 "true",以减少会话状态存储的使用和竞争。将此设置为 "true" 的含义是需要使用会话(不一定更新,但至少请求/查询)才能保持活跃。

  7. maxConnectionLimit - Azure DocumentDB 数据库服务中目标服务终结点允许的最大并发连接数。

  8. maxRetryAttemptsOnThrottledRequests - 当请求失败是因为 Azure DocumentDB 数据库服务对客户端应用了速率限制时的最大重试次数。

  9. maxRetryWaitTimeInSeconds - Azure DocumentDB 数据库服务的最大重试时间(秒)。

  10. consistencyLevel - 与 CosmosClient 一起使用的 一致性级别。默认为 Cosmos SDK 默认值,目前为 'Session'。

  11. preferredLocations - 设置 Azure DocumentDB 数据库服务中地理复制数据库账户的首选位置(区域)。使用分号(;)分隔多个位置。例如:"East US;South Central US;North Europe"。

产品 兼容的和额外的计算目标框架版本。
.NET Framework net462 兼容。 net463 已计算。 net47 已计算。 net471 已计算。 net472 已计算。 net48 已计算。 net481 已计算。
兼容的目标框架
包含的目标框架(在包中)
了解有关 目标框架.NET Standard 的更多信息。

NuGet 包

此包未被任何 NuGet 包使用。

GitHub 仓库

此包未被任何流行的 GitHub 仓库使用。

版本 下载 最后更新
2.0.0 3,945 6/15/2023
2.0.0-preview1 203 4/12/2023
1.1.0 23,011 6/19/2019
1.0.0 17,932 11/15/2017