azure_data_cosmos@0.34.0
Pre-release
Pre-release
0.34.0 (2026-05-29)
Features Added
CosmosErrorcan capture a stack backtrace on construction. Capture is opt-in (off by default; on whenRUST_BACKTRACEis set or when explicit capacities are supplied) and protected against error storms by two configurable per-second limiters on the runtime builder. (#4442)- Introduced
azure_data_cosmos::CosmosErrorand the crate-wideazure_data_cosmos::Result<T>alias, surfacing typedCosmosStatus(with predicate accessors likeis_not_found()/is_throttled()/is_transient()), the originatingCosmosResponse, and the operationDiagnosticsContexton every failure.From<CosmosError> for azure_core::Erroris provided so callers using?againstazure_core::Errorcontinue to compose. (#4442) - Added
RoutingStrategy::PreferredRegionsto allow specifying a fixed region preference order for failover, hedging, and retry. (#4485) - Standardized every client-method options type with a public
operation: OperationOptionsfield andwith_operation_options(OperationOptions) -> Selfsetter, so any per-requestOperationOptionssetting can be configured via any options type. The following options types previously had no way to attachOperationOptionsand now do:ReadContainerOptions,ReadDatabaseOptions,ReplaceContainerOptions,CreateContainerOptions,CreateDatabaseOptions,DeleteContainerOptions,DeleteDatabaseOptions,QueryContainersOptions,QueryDatabasesOptions,ThroughputOptions,ReadFeedRangesOptions. ForCreateContainerOptions/CreateDatabaseOptions/ReplaceContainerOptions, the SDK still forcescontent_response_on_write = Enabledon the resolved options because control-plane mutations require the response body.ReadFeedRangesOptions::operationis currently inert (the underlying routing-map cache does not go through the operation pipeline) but is added for shape consistency with the other options types. (#4447) - Added
new()constructors andwith_xconsuming setters to multi-required-field model types so callers can build them declaratively without struct-literal syntax (which is now blocked by#[non_exhaustive]):VectorEmbedding::new(path, data_type, dimensions, distance_function)+with_path/with_data_type/with_dimensions/with_distance_function;ConflictResolutionPolicy::new(mode)+with_resolution_path/with_resolution_procedure;SpatialIndex::new(path)+with_type(singular pusher ontotypes);CompositeIndexProperty::new(path, order)+with_path/with_order;VectorIndex::new(path, index_type)+with_path/with_index_type. These types do not implementDefault— their constructors require values that have no meaningful default. (#4447) - Derived
DefaultonVectorEmbeddingPolicy,UniqueKeyPolicy,UniqueKey,PropertyPath, andCompositeIndex, and added singularwith_xpushers / setters:VectorEmbeddingPolicy::with_embedding,UniqueKeyPolicy::with_unique_key,UniqueKey::with_path,PropertyPath::with_path, andCompositeIndex::with_property. This matches the existingIndexingPolicy::with_included_pathstyle and lets callers build these policies declaratively without constructing intermediateVecs. (#4447) - Added
QueryFeedPage::as_feed_page()returning&FeedPage<T>, so a query page can be passed to APIs that accept the more generalFeedPagetype. Query-specific metadata (index/query metrics) remains accessible on theQueryFeedPageitself. (#4447) - Added
QueryOptions::with_populate_index_metrics(bool),with_populate_query_metrics(bool), andwith_max_item_count(MaxItemCountHint)setters. These replace the previous pattern of passing rawx-ms-cosmos-populateindexmetrics,x-ms-documentdb-populatequerymetrics, andx-ms-max-item-countvalues throughOperationOptions::with_custom_headersfor query execution.max_item_counttakes the newMaxItemCountHintenum withServerDecidesandLimit(NonZeroU32)variants, so callers don't have to traffic in the-1wire sentinel directly. (#4401) - Added
ContainerClient::patch_item()for applying JSON-Patch-style mutations to a single item. Supportsadd/set/replace/remove/increment/moveops via the newPatchInstructions/PatchOperation/CosmosNumbertypes. AddedPatchItemOptionsfor per-request configuration (max_attempts,session_token, etc.).PatchItemOptionsintentionally does not expose aPreconditionor SQL filter predicate — the driver-side PATCH handler owns the internalIf-Matchend-to-end, and predicate evaluation is out of scope for this preview. The method's rustdoc documents the non-idempotent-under-transport-failure caveat. (#4386) - Support for simple cross-partition queries with
SELECTprojections andWHEREfilters. Cross-partition queries are now done through fan-out in the client, and provide a client-generated continuation token that can be used to resume the query. SeeContainerClient::query_items()andFeedScopefor details. (#4440) - Added
QueryOptions::continuation_tokenandQueryOptions::with_continuation_token(...)for resuming queries from a continuation token. (#4440) - Added a new
FeedOptionstype that wraps the paging knobs (max_item_count,continuation_token) common to feed-style operations, so future feed APIs (change feed, read-feed, etc.) can adopt the same shape without redeclaring fields.QueryOptionsnow embeds it as apub feed: FeedOptionsfield with awith_feed_options(FeedOptions)setter. The existingQueryOptions::with_max_item_countandQueryOptions::with_continuation_tokensetters are retained as convenience functions that mutate the embeddedfeed(they're expected to be used commonly enough to warrant the shortcut). (#4447)
Breaking Changes
- All fallible public APIs now return
azure_data_cosmos::Result<T>(=Result<T, CosmosError>) instead ofazure_core::Result<T>, and the error type was renamedError→CosmosError(withCosmosErrorBuilderfor construction). Categorization moved from aKindenum to predicates onCosmosStatus(is_not_found(),is_throttled(),is_transient(), …); the underlyingazure_core::Erroris still reachable viastd::error::Error::source(). (#4442) - Moved
QueryOptions::max_item_countandQueryOptions::continuation_tokeninto the newQueryOptions::feed: FeedOptionsfield. Callers that read or assign these fields directly should switch tooptions.feed.max_item_count/options.feed.continuation_token. Thewith_max_item_count/with_continuation_tokenconvenience setters onQueryOptionscontinue to work unchanged. (#4447) ThroughputPropertiesis now#[non_exhaustive]and no longer derivesDefault. TheDefaultimpl produced a meaningless wire payload (no manual throughput and no autoscale settings, which would send an empty offer body). Callers should useThroughputProperties::manual(throughput)orThroughputProperties::autoscale(starting_maximum_throughput, increment_percent)instead. (#4447)- Marked the following public model enums and response wrappers as
#[non_exhaustive]to allow future variants/fields to be added without further breaking changes:VectorDataType,VectorDistanceFunction,ConflictResolutionMode,IndexingMode,SpatialType,CompositeIndexOrder,VectorIndexType,BatchResponse,ItemResponse,ResourceResponse<T>,ResponseBody,ResponseHeaders,PartitionKeyVersionandCosmosStatus. Callers must use..wildcard arms inmatches over these enums and cannot construct these structs via struct-literal syntax (the SDK already provides constructors / setters for the constructable types). (#4447) CosmosClientBuilder::buildnow takesAccountReferencedirectly instead ofimpl Into<AccountReference>. Callers should construct anAccountReferenceexplicitly viaAccountReference::with_credentialorAccountReference::with_authentication_keyand pass it in. (#4447)- Replaced
EffectivePartitionKey::min()/EffectivePartitionKey::max()with associated constantsEffectivePartitionKey::MIN/EffectivePartitionKey::MAX. The inner storage also changed fromStringtoCow<'static, str>so the constants can borrow static strings without allocating. Callers should rewriteEffectivePartitionKey::min()asEffectivePartitionKey::MIN.clone()(or just&EffectivePartitionKey::MINfor comparisons). (#4447) - Removed
PartitionKeyValue::undefined()(use the existingPartitionKeyValue::UNDEFINEDassociated constant instead) and replaced the test-onlyPartitionKeyValue::infinity()constructor with a publicly-availablePartitionKeyValue::INFINITYassociated constant. (#4447) - Removed
FeedRange::can_merge()andFeedRange::merge_with(). These are SDK-internal helpers used only by the session-token coalescing pipeline and are now implemented internally. (#4447) - Renamed
CosmosAccountEndpoint→AccountEndpointandCosmosAccountReference→AccountReference. TheCosmosprefix is implied by the containingazure_data_cosmoscrate. (#4447) - Renamed
CosmosAccountReference::with_master_key()towith_authentication_key(). (#4447) - Renamed
FeedPageIterator→QueryPageIteratorandFeedItemIterator→QueryItemIterator. These iterators are only produced by query APIs today; theFeed*names are reserved for future non-query feed APIs. (#4447) - Removed the
request_charge()andsession_token()convenience accessors fromFeedPageandQueryFeedPage. Usepage.headers().request_charge()andpage.headers().session_token()instead — the parsedResponseHeadersalready exposes these values and provides full typed access to every other response header. (#4447) - Tightened
AccountReferenceconstructors.with_credentialnow acceptsimpl Into<AccountEndpoint>instead of a concreteAccountEndpoint. The formerwith_master_keyis renamed towith_authentication_keyand now takesAccountEndpoint(which hasFromStrandFrom<Url>impls) andimpl Into<Secret>for the key. The twoFrom<(AccountEndpoint, _)>/From<(Url, _)>tuple conversions are removed; construct aAccountReferencevia the named constructors instead. (#4447) - Removed
azure_data_cosmos::ConnectionStringfrom the public API. The type was a parsing helper not consumed by any public SDK API. Users who still need support for Connection String parsing can parse the connection string themselves and construct anAccountReferencevia the named constructors. (#4447) - Refactored the response surface to be SDK-owned.
ItemResponsedrops its type parameter (useresponse.into_model::<MyItem>()orresponse.into_body().into_single::<MyItem>());ResourceResponse<T>keeps its parameter so.into_model()?still works without a turbofish.status()now returnsCosmosStatus,headers()returns&ResponseHeaders(typed accessors only —etag(),request_charge(),session_token(),continuation(),activity_id(),substatus(),index_metrics(),query_metrics(),offer_replace_pending(),server_duration_ms(),lsn(),item_lsn(),item_count(), …), andinto_body()returns the SDK-ownedResponseBodyenum (NoPayload/Bytes/Items) withsingle(),items(),into_single::<T>(),into_items::<T>(), andis_empty()helpers.FeedPage::headers()/QueryFeedPage::headers()now return&ResponseHeadersinstead of&azure_core::http::headers::Headers. TheItemResponse::etag()convenience accessor is removed (useresponse.headers().etag()).CosmosStatusis re-exported from the driver and implementsPartialEq<StatusCode>andFrom<CosmosStatus> for StatusCode/u16, so existing comparisons keep working. (#4401)
Other Changes
- Removed the SDK-side
FaultInjectionClientBuilder, parallel duplicate types (FaultInjectionRule,FaultInjectionCondition,FaultInjectionResult,CustomResponse, the matching builders,FaultInjectionErrorType,FaultOperationType), and the SDK-sideFaultClientHTTP wrapper fromazure_data_cosmos::fault_injection. The module is now a pure re-export of the driver's fault-injection types — fault-injection rules flow directly to the driver runtime and are evaluated by the driver's transport-layer fault-injection client.CosmosClientBuilder::with_fault_injectionnow accepts the driver'sVec<Arc<FaultInjectionRule>>directly instead ofFaultInjectionClientBuilder. Callers should construct rules via the re-exportedFaultInjectionRuleBuilderand pass the vector.(#4426) - Removed the
request_url()accessor (gated on thefault_injectionfeature) fromItemResponse/ResourceResponse/BatchResponse. Operations never populated it, so it always returnedNonein current usage. CosmosClientBuilder::with_user_agent_suffix(andCosmosClientOptions::with_user_agent_suffix) now takeUserAgentSuffixinstead ofimpl Into<String>. Callers passing a&strorStringmust construct the value explicitly viaUserAgentSuffix::new(panics on invalid input) orUserAgentSuffix::try_new(returnsOption). Validation rules (max 25 characters, HTTP-header-safe) are now enforced at the construction site instead of being applied silently inside the builder. (#4368)- Changed how continuation tokens are returned. Instead of a
continuation()accessor onQueryFeedPageandFeedPage, continuation tokens are now returned as aOption<ContinuationToken>from theFeedPageIterator::to_continuation_token(&self)method. Generating a continuation token for a cross-partition query requires computation, so this change makes it explicit that callers must opt in to generating a continuation token and allows them to choose when to pay the cost of generation. (#4440) ContainerClient::query_items()now takes aFeedScope(FeedScope::partition(...),FeedScope::range(...), orFeedScope::full_container()) instead of a partition key where()represented cross-partition queries. (#4440)- Replaced
CosmosDiagnosticswithDiagnosticsContext(a re-export ofazure_data_cosmos_driver::diagnostics::DiagnosticsContext). All response types now returnArc<DiagnosticsContext>fromdiagnostics()(the returnedArcderefs transparently toDiagnosticsContextfor read-only inspection, and can be retained alongside a consumed response body). The previousactivity_id() -> Option<&str>andserver_duration_ms() -> Option<f64>accessors onCosmosDiagnosticsare replaced byDiagnosticsContext::activity_id() -> &ActivityIdand per-request server timing viaDiagnosticsContext::requests()[i].server_duration_ms(). (#4376) - Removed
azure_data_cosmos::constants::SubStatusCodeand itsnew/value/from_header_value/From/Display/DebugAPI. The SDK no longer maintains a parallel sub-status-code type. - The
User-Agentheader on every outgoing Cosmos DB request now identifies the wrapping SDK in addition to the driver. The new format isazsdk-rust-cosmos/<sdk-version> azsdk-rust-cosmos-driver/<driver-version> <os>/<arch> rustc/<ver> [suffix], where<sdk-version>is this crate's version. This is wired automatically via the newCosmosDriverRuntimeBuilder::with_wrapping_sdk_identifierAPI in the driver, and lets telemetry distinguish callers usingazure_data_cosmosfrom callers drivingazure_data_cosmos_driverdirectly. No API surface inazure_data_cosmoschanges. (#4465) - The
azure_data_cosmos::constantsmodule is no longer public. It only contained internal HTTP-header-name constants used by the SDK's own pipeline plumbing; nothing from it was intended for consumer use. The one previously-exposed public item (SubStatusCode) is re-exported from the crate root — see the bullet above. (#4447)
Bugs Fixed
- Fixed
CosmosClientBuilder::with_user_agent_suffixnot propagating the suffix to data-plane requests. The suffix was only applied to the SDK's account-metadata pipeline; requests issued through the driver transport pipeline (the vast majority of operations) had aUser-Agentheader without the configured suffix. The suffix is now forwarded toCosmosDriverRuntimeBuilderso it appears on every outgoing request. (#4368)
Other Changes
- Per-partition automatic failover (PPAF) and per-partition circuit breaker (PPCB) are now driven by the
azure_data_cosmos_drivercrate, replacing the SDK's prior implementation. Behavior is unchanged from a configuration standpoint — the existingAZURE_COSMOS_PER_PARTITION_CIRCUIT_BREAKER_ENABLEDenvironment variable continues to work — but routing is now per-(partition_key_range_id, region)instead of per-region. Driver-level changes are described inazure_data_cosmos_driver0.3.0. (#4156)