Azure Cosmos DB .NET SDK for SQL API: Download and release notes

SDK download NuGet
API documentation .NET API reference documentation
Samples .NET code samples
Get started Get started with the Azure Cosmos DB .NET SDK
Web app tutorial Web application development with Azure Cosmos DB
Current supported framework Microsoft .NET Framework 4.5

Release notes


If you are using .NET Framework, please see the latest version 3.x of the .NET SDK, which targets .NET Standard.


  • SDK’s System.Net.Http version now matches what is defined in the NuGet package.
  • Allow write requests to fallback to a different region if the original one fails.
  • Add session retry policy for write request.


  • Fixes tracing race condition for queries which caused empty pages


  • Increased decimal precision size for LINQ queries.
  • Added new classes CompositePath, CompositePathSortOrder, SpatialSpec, SpatialType and PartitionKeyDefinitionVersion
  • Added TimeToLivePropertyPath to DocumentCollection
  • Added CompositeIndexes and SpatialIndexes to IndexPolicy
  • Added Version to PartitionKeyDefinition
  • Added None to PartitionKey


  • Added IdleTcpConnectionTimeout, OpenTcpConnectionTimeout, MaxRequestsPerTcpConnection and MaxTcpConnectionsPerEndpoint to ConnectionPolicy.


  • Diagnostics improvements


  • Added environment variable setting “POCOSerializationOnly”.

  • Removed DocumentDB.Spatial.Sql.dll and now included in Microsoft.Azure.Documents.ServiceInterop.dll


  • Improvement in retry logic during failover for StoredProcedure execute calls.

  • Made DocumentClientEventSource singleton.

  • Fix GatewayAddressCache timeout not honoring ConnectionPolicy RequestTimeout.


  • For direct/TCP transport diagnostics, added TransportException, an internal exception type of the SDK. When present in exception messages, this type prints additional information for troubleshooting client connectivity problems.

  • Added new constructor overload which takes a HttpMessageHandler, a HTTP handler stack to use for sending HttpClient requests (e.g., HttpClientHandler).

  • Fix bug where header with null values were not being handled properly.

  • Improved collection cache validation.


  • Updated System.Net.Security to 4.3.2.


  • Diagnostic tracing improvements


  • Added more resilience to Multi-region request transient failures.


  • Added Multi-region write support.
  • Cross partition query performance improvements with TOP and MaxBufferedItemCount.


  • Added request cancellation support.
  • Added SetCurrentLocation to ConnectionPolicy, which automatically populates the preferred locations based on the region.
  • Fixed Bug in Cross Partition Queries with Min/Max and a filter that matches no documents on an individual partition.
  • DocumentClient methods now have parity with IDocumentClient.
  • Updated direct TCP transport stack to reduce the number of connections established.
  • Added support for Direct Mode TCP for non-Windows clients.


  • Added request cancellation support.
  • Added SetCurrentLocation to ConnectionPolicy, which automatically populates the preferred locations based on the region.
  • Fixed Bug in Cross Partition Queries with Min/Max and a filter that matches no documents on an individual partition.


  • DocumentClient methods now have parity with IDocumentClient.
  • Updated direct TCP transport stack to reduce the number of connections established.
  • Added support for Direct Mode TCP for non-Windows clients.


  • Added ConsistencyLevel Property to FeedOptions.
  • Added JsonSerializerSettings to RequestOptions and FeedOptions.
  • Added EnableReadRequestsFallback to ConnectionPolicy.


  • Fixed KeyNotFoundException for cross partition order by queries in corner cases.
  • Fixed bug where JsonProperty attribute in select clause for LINQ queries was not being honored.


  • Fixed bug that is hit under certain race conditions, that results in intermittent "Microsoft.Azure.Documents.NotFoundException: The read session is not available for the input session token" errors when using Session consistency level.


  • Fixed regression where FeedOptions.MaxItemCount = -1 threw an System.ArithmeticException: page size is negative.
  • Added a new ToString() function to QueryMetrics.
  • Exposed partition statistics on reading collections.
  • Added PartitionKey property to ChangeFeedOptions.
  • Minor bug fixes.


  • Adds the ability to specify unique indexes for the documents by using UniqueKeyPolicy property on the DocumentCollection.
  • Fixed a bug in which the custom JsonSerializer settings were not being honored for some queries and stored procedure execution.


  • Branding change from Azure DocumentDB to Azure Cosmos DB in the API Reference documentation, metadata information in assemblies, and the NuGet package.
  • Expose diagnostic information and latency from the response of requests sent with direct connectivity mode. The property names are RequestDiagnosticsString and RequestLatency on ResourceResponse class.
  • This SDK version requires the latest version of Azure Cosmos DB Emulator available for download from


  • Internal changes for Microsoft friends assemblies.


  • Added several reliability fixes and improvements.


  • Added support for PartitionKeyRangeId as a FeedOption for scoping query results to a specific partition key range value.
  • Added support for StartTime as a ChangeFeedOption to start looking for the changes after that time.


  • Fixed an issue in the JsonSerializable class that may cause a stack overflow exception.


  • Fixed an issue that required recompiling of the application due to the introduction of JsonSerializerSettings as an optional parameter in the DocumentClient constructor.
  • Marked the DocumentClient constructor obsolete that required JsonSerializerSettings as the last parameter to allow for default values of ConnectionPolicy and ConsistencyLevel parameters when passing in JsonSerializerSettings parameter.


  • Added support for specifying custom JsonSerializerSettings while instantiating DocumentClient.


  • Fixed an issue that affected x64 machines that don’t support SSE4 instruction and throw an SEHException when running Azure Cosmos DB SQL queries.


  • Added support for a new consistency level called ConsistentPrefix.
  • Added support for query metrics for individual partitions.
  • Added support for limiting the size of the continuation token for queries.
  • Added support for more detailed tracing for failed requests.
  • Made some performance improvements in the SDK.


  • Functionally same as 1.13.3. Made some internal changes.


  • Functionally same as 1.13.2. Made some internal changes.


  • Fixed an issue that ignored the PartitionKey value provided in FeedOptions for aggregate queries.
  • Fixed an issue in transparent handling of partition management during mid-flight cross-partition Order By query execution.


  • Fixed an issue which caused deadlocks in some of the async APIs when used inside ASP.NET context.


  • Fixes to make SDK more resilient to automatic failover under certain conditions.


  • Fix for an issue that occasionally causes a WebException: The remote name could not be resolved.
  • Added the support for directly reading a typed document by adding new overloads to ReadDocumentAsync API.


  • Added LINQ support for aggregation queries (COUNT, MIN, MAX, SUM, and AVG).
  • Fix for a memory leak issue for the ConnectionPolicy object caused by the use of event handler.
  • Fix for an issue wherein UpsertAttachmentAsync was not working when ETag was used.
  • Fix for an issue wherein cross partition order-by query continuation was not working when sorting on string field.


  • Added support for aggregation queries (COUNT, MIN, MAX, SUM, and AVG). See Aggregation support.
  • Lowered minimum throughput on partitioned collections from 10,100 RU/s to 2500 RU/s.


  • Fix for an issue wherein some of the cross-partition queries were failing in the 32-bit host process.
  • Fix for an issue wherein the session container was not being updated with the token for failed requests in Gateway mode.
  • Fix for an issue wherein a query with UDF calls in projection was failing in some cases.
  • Client side performance fixes for increasing the read and write throughput of the requests.


  • Fix for an issue wherein the session container was not being updated with the token for failed requests.
  • Added support for the SDK to work in a 32-bit host process. Note that if you use cross partition queries, 64-bit host processing is recommended for improved performance.
  • Improved performance for scenarios involving queries with a large number of partition key values in an IN expression.
  • Populated various resource quota stats in the ResourceResponse for document collection read requests when PopulateQuotaInfo request option is set.


  • Minor performance fix for the CreateDocumentCollectionIfNotExistsAsync API introduced in 1.11.0.
  • Performance fix in the SDK for scenarios that involve high degree of concurrent requests.


  • Support for new classes and methods to process the change feed of documents within a collection.
  • Support for cross-partition query continuation and some perf improvements for cross-partition queries.
  • Addition of CreateDatabaseIfNotExistsAsync and CreateDocumentCollectionIfNotExistsAsync methods.
  • LINQ support for system functions: IsDefined, IsNull and IsPrimitive.
  • Fix for automatic binplacing of Microsoft.Azure.Documents.ServiceInterop.dll and DocumentDB.Spatial.Sql.dll assemblies to application’s bin folder when using the Nuget package with projects that have project.json tooling.
  • Support for emitting client side ETW traces which could be helpful in debugging scenarios.


  • Added direct connectivity support for partitioned collections.
  • Improved performance for the Bounded Staleness consistency level.
  • Added Polygon and LineString DataTypes while specifying collection indexing policy for geo-fencing spatial queries.
  • Added LINQ support for StringEnumConverter, IsoDateTimeConverter and UnixDateTimeConverter while translating predicates.
  • Various SDK bug fixes.


  • Fixed an issue that caused the following NotFoundException: The read session is not available for the input session token. This exception occurred in some cases when querying for the read-region of a geo-distributed account.
  • Exposed the ResponseStream property in the ResourceResponse class, which enables direct access to the underlying stream from a response.


  • Modified the ResourceResponse, FeedResponse, StoredProcedureResponse and MediaResponse classes to implement the corresponding public interface so that they can be mocked for test driven deployment (TDD).
  • Fixed an issue that caused a malformed partition key header when using a custom JsonSerializerSettings object for serializing data.


  • Fixed an issue that caused long running queries to fail with error: Authorization token is not valid at the current time.
  • Fixed an issue that removed the original SqlParameterCollection from cross partition top/order-by queries.


  • Added support for parallel queries for partitioned collections.
  • Added support for cross partition ORDER BY and TOP queries for partitioned collections.
  • Fixed the missing references to DocumentDB.Spatial.Sql.dll and Microsoft.Azure.Documents.ServiceInterop.dll that are required when referencing an Azure Cosmos DB project with a reference to the Azure Cosmos DB Nuget package.
  • Fixed the ability to use parameters of different types when using user-defined functions in LINQ.
  • Fixed a bug for globally replicated accounts where Upsert calls were being directed to read locations instead of write locations.
  • Added methods to the IDocumentClient interface that were missing:
    • UpsertAttachmentAsync method that takes mediaStream and options as parameters
    • CreateAttachmentAsync method that takes options as a parameter
    • CreateOfferQuery method that takes querySpec as a parameter.
  • Unsealed public classes that are exposed in the IDocumentClient interface.


  • Added the support for multi-region database accounts.
  • Added support for retry on throttled requests. User can customize the number of retries and the max wait time by configuring the ConnectionPolicy.RetryOptions property.
  • Added a new IDocumentClient interface that defines the signatures of all DocumentClient properties and methods. As part of this change, also changed extension methods that create IQueryable and IOrderedQueryable to methods on the DocumentClient class itself.
  • Added configuration option to set the ServicePoint.ConnectionLimit for a given Azure Cosmos DB endpoint Uri. Use ConnectionPolicy.MaxConnectionLimit to change the default value, which is set to 50.
  • Deprecated IPartitionResolver and its implementation. Support for IPartitionResolver is now obsolete. It's recommended that you use Partitioned Collections for higher storage and throughput.


  • Added an overload to Uri based ExecuteStoredProcedureAsync method that takes RequestOptions as a parameter.


  • Added time to live (TTL) support for documents.


  • Fixed a bug in Nuget packaging of .NET SDK for packaging it as part of an Azure Cloud Service solution.



  • [Fixed] Querying Azure Cosmos DB endpoint throws: 'System.Net.Http.HttpRequestException: Error while copying content to a stream'.


  • Expanded LINQ support including new operators for paging, conditional expressions, and range comparison.
    • Take operator to enable SELECT TOP behavior in LINQ
    • CompareTo operator to enable string range comparisons
    • Conditional (?) and coalesce operators (??)
  • [Fixed] ArgumentOutOfRangeException when combining Model projection with Where-In in a LINQ query. #81


  • [Fixed] If Select is not the last expression the LINQ Provider assumed no projection and produced SELECT * incorrectly. #58


  • Implemented Upsert, Added UpsertXXXAsync methods
  • Performance improvements for all requests
  • LINQ Provider support for conditional, coalesce, and CompareTo methods for strings
  • [Fixed] LINQ provider --> Implement Contains method on List to generate the same SQL as on IEnumerable and Array
  • [Fixed] BackoffRetryUtility uses the same HttpRequestMessage again instead of creating a new one on retry
  • [Obsolete] UriFactory.CreateCollection --> should now use UriFactory.CreateDocumentCollection


  • [Fixed] Localization issues when using non en culture info such as nl-NL, etc.


  • Added ID-based routing
    • New UriFactory helper to assist with constructing ID-based resource links
    • New overloads on DocumentClient to take in URI
  • Added IsValid() and IsValidDetailed() in LINQ for geospatial
  • LINQ Provider support enhanced:
    • Math - Abs, Acos, Asin, Atan, Ceiling, Cos, Exp, Floor, Log, Log10, Pow, Round, Sign, Sin, Sqrt, Tan, Truncate
    • String - Concat, Contains, EndsWith, IndexOf, Count, ToLower, TrimStart, Replace, Reverse, TrimEnd, StartsWith, SubString, ToUpper
    • Array - Concat, Contains, Count
    • IN operator


  • Added support for modifying indexing policies.
    • New ReplaceDocumentCollectionAsync method in DocumentClient
    • New IndexTransformationProgress property in ResourceResponse<T> for tracking percent progress of index policy changes
    • DocumentCollection.IndexingPolicy is now mutable
  • Added support for spatial indexing and query.
    • New Microsoft.Azure.Documents.Spatial namespace for serializing/deserializing spatial types like Point and Polygon
    • New SpatialIndex class for indexing GeoJSON data stored in Cosmos DB
  • [Fixed] Incorrect SQL query generated from a LINQ expression #38.


  • Added a dependency on Newtonsoft.Json v5.0.7.

  • Made changes to support Order By:

    • LINQ provider support for OrderBy() or OrderByDescending()

    • IndexingPolicy to support Order By

      Possible breaking change

      If you have existing code that provisions collections with a custom indexing policy, then your existing code needs to be updated to support the new IndexingPolicy class. If you have no custom indexing policy, then this change does not affect you.


  • Added support for partitioning data by using the new HashPartitionResolver and RangePartitionResolver classes and the IPartitionResolver.
  • Added DataContract serialization.
  • Added GUID support in LINQ provider.
  • Added UDF support in LINQ.


  • GA SDK

Release & Retirement dates

Microsoft provides notification at least 12 months in advance of retiring an SDK in order to smooth the transition to a newer/supported version.

New features and functionality and optimizations are only added to the current SDK, as such it is recommended that you always upgrade to the latest SDK version as early as possible.

Any requests to Azure Cosmos DB using a retired SDK are rejected by the service.

Version Release Date Retirement Date
2.5.1 July 02, 2019 ---
2.4.1 June 20, 2019 ---
2.4.0 May 05, 2019 ---
2.3.0 April 04, 2019 ---
2.2.3 February 11, 2019 ---
2.2.2 February 06, 2019 ---
2.2.1 December 24, 2018 ---
2.2.0 December 07, 2018 ---
2.1.3 October 15, 2018 ---
2.1.2 October 04, 2018 ---
2.1.1 September 27, 2018 ---
2.1.0 September 21, 2018 ---
2.0.0 September 07, 2018 ---
1.22.0 April 19, 2018 ---
1.21.1 March 09, 2018 ---
1.20.2 February 21, 2018 ---
1.20.1 February 05, 2018 ---
1.19.1 November 16, 2017 ---
1.19.0 November 10, 2017 ---
1.18.1 November 07, 2017 ---
1.18.0 October 17, 2017 ---
1.17.0 August 10, 2017 ---
1.16.1 August 07, 2017 ---
1.16.0 August 02, 2017 ---
1.15.0 June 30, 2017 ---
1.14.1 May 23, 2017 ---
1.14.0 May 10, 2017 ---
1.13.4 May 09, 2017 ---
1.13.3 May 06, 2017 ---
1.13.2 April 19, 2017 ---
1.13.1 March 29, 2017 ---
1.13.0 March 24, 2017 ---
1.12.2 March 20, 2017 ---
1.12.1 March 14, 2017 ---
1.12.0 February 15, 2017 ---
1.11.4 February 06, 2017 ---
1.11.3 January 26, 2017 ---
1.11.1 December 21, 2016 ---
1.11.0 December 08, 2016 ---
1.10.0 September 27, 2016 ---
1.9.5 September 01, 2016 ---
1.9.4 August 24, 2016 ---
1.9.3 August 15, 2016 ---
1.9.2 July 23, 2016 ---
1.8.0 June 14, 2016 ---
1.7.1 May 06, 2016 ---
1.7.0 April 26, 2016 ---
1.6.3 April 08, 2016 ---
1.6.2 March 29, 2016 ---
1.5.3 February 19, 2016 ---
1.5.2 December 14, 2015 ---
1.5.1 November 23, 2015 ---
1.5.0 October 05, 2015 ---
1.4.1 August 25, 2015 ---
1.4.0 August 13, 2015 ---
1.3.0 August 05, 2015 ---
1.2.0 July 06, 2015 ---
1.1.0 April 30, 2015 ---
1.0.0 April 08, 2015 ---


1. How will customers be notified of the retiring SDK?

Microsoft will provide 12 month advance notification to the end of support of the retiring SDK in order to facilitate a smooth transition to a supported SDK. Further, customers will be notified through various communication channels – Azure Management Portal, Developer Center, blog post, and direct communication to assigned service administrators.

2. Can customers author applications using a "to-be" retired Azure Cosmos DB SDK during the 12 month period?

Yes, customers will have full access to author, deploy and modify applications using the "to-be" retired Azure Cosmos DB SDK during the 12 month grace period. During the 12 month grace period, customers are advised to migrate to a newer supported version of Azure Cosmos DB SDK as appropriate.

3. Can customers author and modify applications using a retired Azure Cosmos DB SDK after the 12 month notification period?

After the 12 month notification period, the SDK will be retired. Any access to Azure Cosmos DB by an applications using a retired SDK will not be permitted by the Azure Cosmos DB platform. Further, Microsoft will not provide customer support on the retired SDK.

4. What happens to Customer’s running applications that are using unsupported Azure Cosmos DB SDK version?

Any attempts made to connect to the Azure Cosmos DB service with a retired SDK version will be rejected.

5. Will new features and functionality be applied to all non-retired SDKs?

New features and functionality will only be added to new versions. If you are using an old, non-retired, version of the SDK your requests to Azure Cosmos DB will still function as previous but you will not have access to any new capabilities.

6. What should I do if I cannot update my application before a cut-off date?

We recommend that you upgrade to the latest SDK as early as possible. Once an SDK has been tagged for retirement you will have 12 months to update your application. If, for whatever reason, you cannot complete your application update within this timeframe then please contact the Cosmos DB Team and request their assistance before the cutoff date.

See also

To learn more about Cosmos DB, see Microsoft Azure Cosmos DB service page.