Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync 2.0.0

Prefix Reserved
dotnet add package Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync --version 2.0.0                
NuGet\Install-Package Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync -Version 2.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync --version 2.0.0                
#r "nuget: Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync, 2.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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

In .Net 4.6.2, asp.net enables developer plug in async version of SessionState module which is a good fit for the non-in-memory SessionState data store. This SessionState provider uses SQL Server as the data store and leverages async database operation to provide better scability.

Before you can specify this new async providers, you need to setup the new async SessionStateModule as described here.

Then, register your new provider like so:

  <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>

Note For the best scalability, it is recommended to configure your CosmosDB provider with "wildcard" partitioning. For update-compatibility purposes, this is not the default. Please read about partitionKeyPath and partitionNumUsedByProvider below.

Settings for Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync

  1. cosmosDBEndPointSettingKey - The appsetting key name which points to a CosmosDB end point

  2. cosmosDBAuthKeySettingKey - The appsetting key name which points to a CosmosDB auth key

  3. offerThroughput - The offer throughput provisioned for a collection in measurement of Requests-per-Unit in the Azure DocumentDB database service. If the collection provided doesn't exist, the provider will create a collection with this offerThroughput. If set to "0", collection will be set to use the default throughput of the database.

  4. connectionMode - Direct | Gateway

  5. requestTimeout - The request timeout in seconds when connecting to the Azure DocumentDB database service.

  6. skipKeepAliveWhenUnused - This setting will skip the call to update expiration time on requests that did not read or write session state. The default is "false" to maintain compatibility with previous behavior. But certain applications (like MVC) where there can be an abundance of requests processed that never even look at session state could benefit from setting this to "true" to reduce the use of and contention within the session state store. Setting this to "true" does mean that a session needs to be used (not necessarily updated, but at least requested/queried) to stay alive.

  7. maxConnectionLimit - maximum number of concurrent connections allowed for the target service endpoint in the Azure DocumentDB database service.

  8. maxRetryAttemptsOnThrottledRequests - the maximum number of retries in the case where the request fails because the Azure DocumentDB database service has applied rate limiting on the client.

  9. maxRetryWaitTimeInSeconds - The maximum retry time in seconds for the Azure DocumentDB database service.

  10. consistencyLevel - The Consistency Level to use with the CosmosClient. Default is the Cosmos SDK default, which is currently 'Session'.

  11. preferredLocations - Sets the preferred locations(regions) for geo-replicated database accounts in the Azure DocumentDB database service. Use ';' to split multiple locations. e.g. "East US;South Central US;North Europe"

Product Compatible and additional computed target framework versions.
.NET Framework net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 8,031 6/15/2023
2.0.0-preview1 229 4/12/2023
1.1.0 23,334 6/19/2019
1.0.0 17,989 11/15/2017