From 99e0015a7ebf470ffaf81e309e74fa3e4dccae6c Mon Sep 17 00:00:00 2001 From: Steve Molloy Date: Fri, 27 Jan 2023 17:21:42 -0800 Subject: [PATCH] Allow pre-provisioned throughput (#68) * Allowing to use provisioned throughput by setting offerThroughput value to "0". * Round-about way of re-writing this onto current main, but I wanted to keep the original PR commit in the list for credit. --------- Co-authored-by: Al Baymar --- docs/CosmosDBSessionStateProviderAsync.md | 2 +- .../CosmosDBSessionStateProviderAsync.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/CosmosDBSessionStateProviderAsync.md b/docs/CosmosDBSessionStateProviderAsync.md index fd1b8ff..6bd6185 100644 --- a/docs/CosmosDBSessionStateProviderAsync.md +++ b/docs/CosmosDBSessionStateProviderAsync.md @@ -22,7 +22,7 @@ Then, register your new provider like so: 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. +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 diff --git a/src/CosmosDBSessionStateProviderAsync/CosmosDBSessionStateProviderAsync.cs b/src/CosmosDBSessionStateProviderAsync/CosmosDBSessionStateProviderAsync.cs index d6b26f6..2d1862e 100644 --- a/src/CosmosDBSessionStateProviderAsync/CosmosDBSessionStateProviderAsync.cs +++ b/src/CosmosDBSessionStateProviderAsync/CosmosDBSessionStateProviderAsync.cs @@ -887,7 +887,7 @@ namespace Microsoft.AspNet.SessionState IndexingPolicy = s_indexNone }; - ContainerResponse response = await database.CreateContainerIfNotExistsAsync(containerProperties, s_offerThroughput).ConfigureAwait(false); + ContainerResponse response = await database.CreateContainerIfNotExistsAsync(containerProperties, s_offerThroughput > 0 ? s_offerThroughput : (int?)null).ConfigureAwait(false); if (response?.Resource?.PartitionKeyPath != partitionKeyPath) {