Kit de développement logiciel .NET Azure Cosmos DB pour l’API SQL : Téléchargement et notes de publicationAzure Cosmos DB .NET SDK for SQL API: Download and release notes

Téléchargement du Kit de développement logiciel (SDK)SDK download NuGetNuGet
Documentation de l’APIAPI documentation Documentation de référence sur l’API .NET.NET API reference documentation
ExemplesSamples Exemples de code .NET.NET code samples
Prise en mainGet started Prise en main du Kit de développement logiciel (SDK) .NET Azure Cosmos DBGet started with the Azure Cosmos DB .NET SDK
Didacticiel d’application webWeb app tutorial Développement d’applications web avec Azure Cosmos DBWeb application development with Azure Cosmos DB
Infrastructure actuellement prise en chargeCurrent supported framework Microsoft .NET Framework 4.5Microsoft .NET Framework 4.5

Notes de publicationRelease notes


Si vous utilisez .NET Framework, consultez la dernière version 3.x du SDK .NET, qui cible .NET Standard.If you are using .NET Framework, please see the latest version 3.x of the .NET SDK, which targets .NET Standard.


  • Added RequestDiagnosticsString to FeedResponse


  • Added support for arrays and objects in order by queries
  • Handle effective partition key collisions
  • Added LINQ support for multiple OrderBy operators with ThenBy operator
  • Custom serialization settings are now applied to all upsert and replace operations
  • Fixed AysncCache deadlock issue so that it will work with a single-threaded task scheduler


  • Added PortReusePolicy to ConnectionPolicy
  • Fixed ntdll!RtlGetVersion TypeLoadException issue when SDK is used in a UWP app


  • 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


  • Made assembly version and file version same as nuget package version.


  • 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 constuctor 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.
  • Fixed bug where MaxBufferedItemCount was not being honored causing out of memory issues.


  • 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 JsonPropery 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.


  • Improved cross partition query performance when the MaxDegreeOfParallelism property is set to -1 in FeedOptions.
  • 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 DocumentDB API queries.


  • Added support for Request Unit per Minute (RU/m) feature.
  • 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.


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


  • Minor performance fix for the CreateDocumentCollectionIfNotExistsAsync API introduced in 1.11.0.
  • Peformance 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 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 a DocumentDB project with a reference to the DocumentDB 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 DocumenClient 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 DocumentDB 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 a Azure Cloud Service solution.



  • [Fixed] Querying DocumentDB 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 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.


  • 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 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 DocumentDB.
  • [Fixed] : Incorrect SQL query generated from linq expression. #38


  • Dependency on Newtonsoft.Json v5.0.7.

  • Changes to support Order By:

    • LINQ provider support for OrderBy() or OrderByDescending().
    • IndexingPolicy to support Order By.

    NB: Possible breaking change

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


  • Support for partitioning data by using the new HashPartitionResolver and RangePartitionResolver classes and the IPartitionResolver.
  • DataContract serialization.
  • Guid support in LINQ provider.
  • 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.


All versions 1.x of the .NET SDK for SQL API will be retired on August 30, 2020.

Version Release Date Retirement Date
2.8.1 October 11, 2019 ---
2.7.0 September 23, 2019 ---
2.6.0 August 30, 2019 ---
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 August 30, 2020
1.21.1 March 09, 2018 August 30, 2020
1.20.2 February 21, 2018 August 30, 2020
1.20.1 February 05, 2018 August 30, 2020
1.19.1 November 16, 2017 August 30, 2020
1.19.0 November 10, 2017 August 30, 2020
1.18.1 November 07, 2017 August 30, 2020
1.18.0 October 17, 2017 August 30, 2020
1.17.0 August 10, 2017 August 30, 2020
1.16.1 August 07, 2017 August 30, 2020
1.16.0 August 02, 2017 August 30, 2020
1.15.0 June 30, 2017 August 30, 2020
1.14.1 May 23, 2017 August 30, 2020
1.14.0 May 10, 2017 August 30, 2020
1.13.4 May 09, 2017 August 30, 2020
1.13.3 May 06, 2017 August 30, 2020
1.13.2 April 19, 2017 August 30, 2020
1.13.1 March 29, 2017 August 30, 2020
1.13.0 March 24, 2017 August 30, 2020
1.12.1 March 14, 2017 August 30, 2020
1.12.0 February 15, 2017 August 30, 2020
1.11.4 February 06, 2017 August 30, 2020
1.11.3 January 26, 2017 August 30, 2020
1.11.1 December 21, 2016 August 30, 2020
1.11.0 December 08, 2016 August 30, 2020
1.10.0 September 27, 2016 August 30, 2020
1.9.5 September 01, 2016 August 30, 2020
1.9.4 August 24, 2016 August 30, 2020
1.9.3 August 15, 2016 August 30, 2020
1.9.2 July 23, 2016 August 30, 2020
1.8.0 June 14, 2016 August 30, 2020
1.7.1 May 06, 2016 August 30, 2020
1.7.0 April 26, 2016 August 30, 2020
1.6.3 April 08, 2016 August 30, 2020
1.6.2 March 29, 2016 August 30, 2020
1.5.3 February 19, 2016 August 30, 2020
1.5.2 December 14, 2015 August 30, 2020
1.5.1 November 23, 2015 August 30, 2020
1.5.0 October 05, 2015 August 30, 2020
1.4.1 August 25, 2015 August 30, 2020
1.4.0 August 13, 2015 August 30, 2020
1.3.0 August 05, 2015 August 30, 2020
1.2.0 July 06, 2015 August 30, 2020
1.1.0 April 30, 2015 August 30, 2020
1.0.0 April 08, 2015 August 30, 2020

Forum Aux QuestionsFAQ

1. Comment les clients vont-ils être informés du retrait du kit de développement logiciel ?1. How will customers be notified of the retiring SDK?

Microsoft notifiera 12 mois à l’avance à la fin de l’assistance du kit de développement logiciel à retirer afin de faciliter une transition en douceur vers un kit de développement logiciel faisant l’objet d’une assistance.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. En outre, les clients sont informés par différents canaux de communication (portail de gestion Azure, centre de développement, billet de blog et communication directe avec des administrateurs de service affectés.Further, customers will be notified through various communication channels – Azure Management Portal, Developer Center, blog post, and direct communication to assigned service administrators.

2. Les clients peuvent-ils créer des applications à l’aide d’un kit de développement Azure Cosmos DB destiné à être retiré pendant le préavis de 12 mois ?2. Can customers author applications using a "to-be" retired Azure Cosmos DB SDK during the 12 month period?

Oui, les clients ont un accès complet à créer, déployer et modifier des applications à l’aide du kit de développement logiciel Azure Cosmos DB dont le kit de développement logiciel va être retiré pendant le préavis de 12 mois.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. Pendant cette période de 12 mois, il est conseillé aux clients de migrer vers une version plus récente du kit de développement logiciel de la version Azure Cosmos DB prise en charge comme il convient.During the 12 month grace period, customers are advised to migrate to a newer supported version of Azure Cosmos DB SDK as appropriate.

3. Les clients peuvent-ils créer et modifier des applications à l’aide d’un kit de développement logiciel Azure Cosmos DB après la période de notification de 12 mois ?3. Can customers author and modify applications using a retired Azure Cosmos DB SDK after the 12 month notification period?

Après la période de notification de 12 mois, le kit de développement logiciel est retiré.After the 12 month notification period, the SDK will be retired. Tout accès à Azure Cosmos DB par une application utilisant un kit de développement logiciel mis hors-service ne sera pas possible par la plateforme de Azure Cosmos DB.Any access to Azure Cosmos DB by an applications using a retired SDK will not be permitted by the Azure Cosmos DB platform. En outre, Microsoft ne fournira pas le support technique sur le kit de développement logiciel mis hors-service.Further, Microsoft will not provide customer support on the retired SDK.

4. Que se passe-t-il pour les applications en cours d’exécution du client qui utilisent la version de kit de développement logiciel Azure Cosmos DB non prise en charge ?4. What happens to Customer’s running applications that are using unsupported Azure Cosmos DB SDK version?

Toutes les tentatives de connexion au service Azure Cosmos DB avec une version de kit de développement logiciel mis hors-service sont rejetées.Any attempts made to connect to the Azure Cosmos DB service with a retired SDK version will be rejected.

5. Les nouvelles fonctionnalités s’appliqueront-elles à tous les kits SDK non mis hors-service ?5. Will new features and functionality be applied to all non-retired SDKs?

Les nouvelles fonctions et fonctionnalités seront ajoutées aux nouvelles versions uniquement.New features and functionality will only be added to new versions. Si vous utilisez une version ancienne du kit de développement logiciel non mis hors-service, vos demandes de Azure Cosmos DB vont continuer de fonctionner comme avant, mais sans que vous ayez accès aux nouvelles possibilités.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. Que dois-je faire si je ne parviens pas à mettre à jour mon application avant la date limite ?6. What should I do if I cannot update my application before a cut-off date?

Nous vous recommandons de mettre à niveau vers la dernière version du kit de développement logiciel dès que possible.We recommend that you upgrade to the latest SDK as early as possible. Une fois le kit de développement logiciel marqué pour la mise hors-service, vous aurez 12 mois pour mettre à jour votre application.Once an SDK has been tagged for retirement you will have 12 months to update your application. Si, pour une raison quelconque, vous ne pouvez pas terminer votre mise à jour de l’application au cours de cette période, contactez l’équipe Cosmos DB et demandez-lui de l’aide avant la date limite.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.

Voir aussiSee also

Pour en savoir plus sur Cosmos DB, consultez la page du service Microsoft Azure Cosmos DB.To learn more about Cosmos DB, see Microsoft Azure Cosmos DB service page.