azure_data_cosmos@0.36.0
Pre-release
Pre-release
0.36.0 (2026-06-19)
Features Added
- Derived
SafeDebugonCosmosCredential,ItemResponse,ResourceResponse<T>, andBatchResponse. (#4512) - Added standard derives (
Clone,Copy,PartialEq,Eq,Hash,Serialize,Deserialize) toConsistencyLevelandRoutingStrategy. (#4512) Query::with_textnow acceptsimpl Into<String>. (#4512)- Exposed
CosmosRuntimeand a runtime-awareCosmosClientBuilder, splitting the Cosmos client into a per-process runtime (transport / cert / proxy / UA defaults) and per-client driver (operation defaults, fault injection, throughput-control groups), and re-exporting the driver's options surface fromazure_data_cosmos::options:- New
CosmosRuntimeandCosmosRuntimeBuildertypes. A default process-wide runtime is initialized lazily; users can configure their own runtime throughCosmosRuntimeBuilderand attach it viaCosmosClientBuilder::with_runtime. The runtime builder exposes:with_connection_pool(ConnectionPoolOptions)— runtime-wide transport / cert / proxy settings.with_default_operation_options(OperationOptions)— runtime-defaultOperationOptions.with_user_agent_suffix(UserAgentSuffix)— runtime-default User-Agent suffix.with_cpu_refresh_interval(Duration)— diagnostics sampler interval.build()— auto-applies anazsdk-rust-cosmos/<crate-version>wrapping SDK identifier so wire User-Agent strings always advertise the SDK alongside any custom suffix.
- New per-client setters on
CosmosClientBuilder:with_runtime(CosmosRuntime)— attach an explicit runtime; when not set,build()resolvesCosmosRuntime::global()lazily.with_default_operation_options(OperationOptions)— client-level defaultOperationOptions(overrides runtime defaults; overridden by per-call options).with_partition_failover_options(PartitionFailoverOptions)— configures the driver's per-partition circuit-breaker / failover tuning for this client; when unset, the driver falls back toPartitionFailoverOptions::default(), which honors theAZURE_COSMOS_PPCB_*environment variables.with_fault_injection_rules(Vec<Arc<FaultInjectionRule>>) -> Result<Self>— registers fault-injection rules on this specific client (gated onfault_injection).register_throughput_control_group(ThroughputControlGroupOptions) -> Result<Self>— registers a throughput-control group for this client's driver.
- New re-exports from
azure_data_cosmos::options(so users configuring a custom runtime don't have to take a direct dependency on the driver crate):ConnectionPoolOptions,ConnectionPoolOptionsBuilder,ServerCertificateValidation,PartitionFailoverOptions,PartitionFailoverOptionsBuilder,ThroughputControlOptions,ThroughputControlOptionsBuilder, andThroughputControlOptionsView. - New nested
OperationOptions::throughput_controlgroup lets callers setthroughput_bucketandpriority_levelper request without first registering a throughput-control group; registered groups are still consulted as fallbacks throughThroughputControlOptions::group_name. (See the driver CHANGELOG for the full per-field layering and header-emission rules.)
- New
Breaking Changes
- Reorganized the public API: types are now grouped under
models,diagnostics,feed, andoptions; thequery,regions, androuting_strategymodules were removed; the previously#[doc(hidden)]feature-gated builder methods onCosmosClientBuilderare now visible (and remain feature-gated);PartitionKey::EMPTY, itsDefaultimpl, andFrom<()> for PartitionKeywere removed (use the query/feed APIs for cross-partition operations); andETagis no longer re-exported fromazure_data_cosmos::options— useazure_core::http::Etagdirectly (construct viaEtag::from(&str)/Etag::from(String)). See the PR for the full list of moves and import paths. (#4512) - Renamed
CosmosClientBuilder::with_operation_optionstoCosmosClientBuilder::with_default_operation_optionsto reflect the fact that it specifies defaults for per-operation options rather than actual client-level options. (#4588) TransactionalBatch::{create_item, upsert_item, replace_item}andTransactionalBatchOperationResult::into_modelnow returnazure_data_cosmos::Result<_>instead ofResult<_, serde_json::Error>. The underlyingresource_bodyis now stored asOption<Box<serde_json::value::RawValue>>and exposed via a newresource_body()accessor. (#4512)DatabaseProperties::idis nowOption<String>(previouslyString) to match the wire schema. (#4512)- Partition Circuit Breaker (PPCB) is now ENABLED by default. To disable it, set
PartitionFailoverOptions::circuit_breaker_enabledtofalsewhen configuring aCosmosClientor set theAZURE_COSMOS_PPCB_ENABLEDenvironment variable tofalse. (#4588) CosmosClientBuilderhas been slimmed to a runtime-aware surface. Per-runtime concerns (transport, cert validation, proxy, UA defaults) move ontoCosmosRuntimeand are shared across clients; per-client concerns (operation defaults, FI rules, throughput-control groups) stay on the builder (#4588). Migration impact:with_proxy_allowed— removed. Move toCosmosRuntimeBuilder::with_connection_pool(ConnectionPoolOptionsBuilder::new().with_proxy_allowed(true).build()).with_throttling_retry_options— removed. The throttle settings now live onOperationOptions; usewith_default_operation_options(OperationOptionsBuilder::new().with_throttling_retry_options(...).build())(or attach to aCosmosRuntimefor process-wide defaults).with_fault_injection— renamed towith_fault_injection_rulesand now returnsResult<Self>to surface duplicate-ID errors at registration time.with_throughput_control_group— renamed toregister_throughput_control_groupand now returnsResult<Self>. Throughput-control groups are now a per-client (driver-level) concept only;CosmosRuntimeBuilderdoes not expose a corresponding registration method.with_driver_runtime_builder— replaced bywith_runtime(CosmosRuntime). The__internal_in_memory_emulatorharness builds its runtime viaCosmosRuntimeBuilder::from(driver_builder)(theFrom<CosmosDriverRuntimeBuilder>escape hatch).- The
allow_invalid_certificatesCargo feature has been removed. The capability is now in the default feature set but requires explicit opt-in viaCosmosRuntimeBuilder::with_connection_pool(ConnectionPoolOptionsBuilder::new().with_server_certificate_validation(ServerCertificateValidation::RequiredUnlessEmulator).build()). The newRequiredUnlessEmulatorpolicy is not a blanket "disable validation" knob — it validates the server certificate normally and only relaxes validation for detected Cosmos DB emulator hosts (viaAccountEndpoint+Regionheuristics, or theAZURE_COSMOS_EMULATOR_HOSTenvironment variable). See the driver CHANGELOG for the underlyingEmulatorServerCertValidation→ServerCertificateValidationrename.
- Per-account driver caching has been removed from the underlying runtime — each
CosmosClient::build(...)now constructs a freshCosmosDriver. Clients sharing the sameCosmosRuntimecontinue to share transport pools, sampler, account cache, etc.; only the per-accountCosmosDriverinstance is no longer reused. (#4588)
Bugs Fixed
403/1008 (DatabaseAccountNotFound)and403/3 (WriteForbidden)now trigger an account-topology refresh and retry against the refreshed endpoints instead of bubbling up. (#4590)- Gateway-mode transport connect failures no longer bump the per-partition circuit breaker counter; only the endpoint-unavailable mark is emitted. (#4590)
403/3 (WriteForbidden)and403/1008 (DatabaseAccountNotFound)on a PPCB-managed multi-write partition no longer mark the endpoint unavailable; the per-partition counter drives failover so other partitions on the same endpoint keep writing normally. (#4590)- The per-partition circuit breaker override now respects
OperationOptions::excluded_regions; previously a tripped override could silently route to a region the caller had excluded. (#4590)
Other Changes
DatabaseClient::read_throughputandbegin_replace_throughputno longer panic in release builds if the service returns an offer without_rid; they now return a syntheticCosmosError. (#4512)azure_data_cosmos::erroris now a public module, andContainerClient/DatabaseClientare re-exported at the crate root. (#4512)- Documented that control-plane create/replace methods (
CosmosClient::create_database,DatabaseClient::create_container,ContainerClient::replace, and the throughput-replace methods) always return the resource body regardless ofContentResponseOnWrite, and pointedCosmosClient's rustdoc at theCosmosClient::builder()factory. (#4512)