Skip to content

Commit 1313c7c

Browse files
Minor Fix for @azure/cosmos4.6.0 (#35968)
### Packages impacted by this PR @azure/cosmos ### Issues associated with this PR ### Describe the problem that is addressed by this PR ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? ### Are there test cases added in this PR? _(If not, why?)_ ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [ ] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [ ] Added a changelog (if necessary) --------- Co-authored-by: ajnovice <[email protected]> Co-authored-by: Ajay Singh <[email protected]>
1 parent 92c512e commit 1313c7c

File tree

9 files changed

+169
-121
lines changed

9 files changed

+169
-121
lines changed

sdk/cosmosdb/cosmos/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Release History
2-
## 4.6.0 (2025-09-15)
2+
## 4.6.0 (2025-10-01)
33

44
### Features Added
55

@@ -17,6 +17,7 @@ await container.item("1").delete(requestOptions);
1717
### Bugs Fixed
1818
- [#35875](https://github.com/Azure/azure-sdk-for-js/issues/35875) Fixed the per-operation partition key format in the batch API to match the API-level partition key,
1919
preventing partitionKeyMismatch error when an optional partition key value is provided in the operationInput
20+
- [#35967](https://github.com/Azure/azure-sdk-for-js/issues/35967) Changed the default values of `enablePartitionLevelFailover` and `enablePartitionLevelCircuitBreaker` flags to `true` in the connection policy.
2021

2122
## 4.5.1 (2025-09-01)
2223

sdk/cosmosdb/cosmos/review/cosmos-node.api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ export class DatabaseAccount {
929929
readonly databasesLink: string;
930930
// (undocumented)
931931
readonly enableMultipleWritableLocations: boolean;
932-
readonly enablePerPartitionFailoverBehavior: boolean;
932+
readonly enablePerPartitionFailover: boolean;
933933
// @deprecated
934934
get MaxMediaStorageUsageInMB(): number;
935935
readonly maxMediaStorageUsageInMB: number;
@@ -1326,7 +1326,7 @@ export class GlobalEndpointManager {
13261326
preferredLocationsCount: number;
13271327
refreshEndpointList(diagnosticNode: DiagnosticNodeInternal): Promise<void>;
13281328
// (undocumented)
1329-
resolveServiceEndpoint(diagnosticNode: DiagnosticNodeInternal, resourceType: ResourceType, operationType: OperationType, startServiceEndpointIndex?: number, options?: SharedOptions | ChangeFeedIteratorOptions): Promise<string>;
1329+
resolveServiceEndpoint(diagnosticNode: DiagnosticNodeInternal, resourceType: ResourceType, operationType: OperationType, startServiceEndpointIndex?: number): Promise<string>;
13301330
}
13311331

13321332
// @public (undocumented)

sdk/cosmosdb/cosmos/src/ClientContext.ts

Lines changed: 77 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,13 @@ export class ClientContext {
148148
this.applySessionToken(request);
149149

150150
// read will use ReadEndpoint since it uses GET operation
151-
request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(
152-
diagnosticNode,
153-
request.resourceType,
154-
request.operationType,
155-
0,
156-
options,
157-
);
151+
request.endpoint = await this.globalEndpointManager.resolveServiceEndpointInternal({
152+
diagnosticNode: diagnosticNode,
153+
resourceType: request.resourceType,
154+
operationType: request.operationType,
155+
startServiceEndpointIndex: 0,
156+
excludedLocations: options?.excludedLocations,
157+
});
158158
const response = await executePlugins(
159159
diagnosticNode,
160160
request,
@@ -219,13 +219,13 @@ export class ClientContext {
219219
if (query !== undefined) {
220220
request.method = HTTPMethod.post;
221221
}
222-
request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(
223-
diagnosticNode,
224-
request.resourceType,
225-
request.operationType,
226-
0,
227-
options,
228-
);
222+
request.endpoint = await this.globalEndpointManager.resolveServiceEndpointInternal({
223+
diagnosticNode: diagnosticNode,
224+
resourceType: request.resourceType,
225+
operationType: request.operationType,
226+
startServiceEndpointIndex: 0,
227+
excludedLocations: options?.excludedLocations,
228+
});
229229
request.headers = await this.buildHeaders(request);
230230

231231
if (startEpk !== undefined && endEpk !== undefined) {
@@ -282,13 +282,13 @@ export class ClientContext {
282282
operationType: OperationType.Read,
283283
resourceType,
284284
});
285-
request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(
286-
diagnosticNode,
287-
request.resourceType,
288-
request.operationType,
289-
0,
290-
options,
291-
);
285+
request.endpoint = await this.globalEndpointManager.resolveServiceEndpointInternal({
286+
diagnosticNode: diagnosticNode,
287+
resourceType: request.resourceType,
288+
operationType: request.operationType,
289+
startServiceEndpointIndex: 0,
290+
excludedLocations: options?.excludedLocations,
291+
});
292292
request.headers = await this.buildHeaders(request);
293293
if (correlatedActivityId !== undefined) {
294294
request.headers[HttpHeaders.CorrelatedActivityId] = correlatedActivityId;
@@ -368,13 +368,13 @@ export class ClientContext {
368368
request.partitionKeyRangeId = partitionKeyRangeId;
369369
this.applySessionToken(request);
370370
// deleteResource will use WriteEndpoint since it uses DELETE operation
371-
request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(
372-
diagnosticNode,
373-
request.resourceType,
374-
request.operationType,
375-
0,
376-
options,
377-
);
371+
request.endpoint = await this.globalEndpointManager.resolveServiceEndpointInternal({
372+
diagnosticNode: diagnosticNode,
373+
resourceType: request.resourceType,
374+
operationType: request.operationType,
375+
startServiceEndpointIndex: 0,
376+
excludedLocations: options?.excludedLocations,
377+
});
378378
const response = await executePlugins(
379379
diagnosticNode,
380380
request,
@@ -433,13 +433,13 @@ export class ClientContext {
433433
this.applySessionToken(request);
434434

435435
// patch will use WriteEndpoint
436-
request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(
437-
diagnosticNode,
438-
request.resourceType,
439-
request.operationType,
440-
0,
441-
options,
442-
);
436+
request.endpoint = await this.globalEndpointManager.resolveServiceEndpointInternal({
437+
diagnosticNode: diagnosticNode,
438+
resourceType: request.resourceType,
439+
operationType: request.operationType,
440+
startServiceEndpointIndex: 0,
441+
excludedLocations: options?.excludedLocations,
442+
});
443443
const response = await executePlugins(
444444
diagnosticNode,
445445
request,
@@ -494,13 +494,13 @@ export class ClientContext {
494494
// create will use WriteEndpoint since it uses POST operation
495495
this.applySessionToken(request);
496496

497-
request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(
498-
diagnosticNode,
499-
request.resourceType,
500-
request.operationType,
501-
0,
502-
options,
503-
);
497+
request.endpoint = await this.globalEndpointManager.resolveServiceEndpointInternal({
498+
diagnosticNode: diagnosticNode,
499+
resourceType: request.resourceType,
500+
operationType: request.operationType,
501+
startServiceEndpointIndex: 0,
502+
excludedLocations: options?.excludedLocations,
503+
});
504504
const response = await executePlugins(
505505
diagnosticNode,
506506
request,
@@ -602,13 +602,13 @@ export class ClientContext {
602602
this.applySessionToken(request);
603603

604604
// replace will use WriteEndpoint since it uses PUT operation
605-
request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(
606-
diagnosticNode,
607-
request.resourceType,
608-
request.operationType,
609-
0,
610-
options,
611-
);
605+
request.endpoint = await this.globalEndpointManager.resolveServiceEndpointInternal({
606+
diagnosticNode: diagnosticNode,
607+
resourceType: request.resourceType,
608+
operationType: request.operationType,
609+
startServiceEndpointIndex: 0,
610+
excludedLocations: options?.excludedLocations,
611+
});
612612
const response = await executePlugins(
613613
diagnosticNode,
614614
request,
@@ -664,13 +664,13 @@ export class ClientContext {
664664
this.applySessionToken(request);
665665

666666
// upsert will use WriteEndpoint since it uses POST operation
667-
request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(
668-
diagnosticNode,
669-
request.resourceType,
670-
request.operationType,
671-
0,
672-
options,
673-
);
667+
request.endpoint = await this.globalEndpointManager.resolveServiceEndpointInternal({
668+
diagnosticNode: diagnosticNode,
669+
resourceType: request.resourceType,
670+
operationType: request.operationType,
671+
startServiceEndpointIndex: 0,
672+
excludedLocations: options?.excludedLocations,
673+
});
674674
const response = await executePlugins(
675675
diagnosticNode,
676676
request,
@@ -726,13 +726,13 @@ export class ClientContext {
726726
request.headers = await this.buildHeaders(request);
727727
request.partitionKeyRangeId = partitionKeyRangeId;
728728
// executeStoredProcedure will use WriteEndpoint since it uses POST operation
729-
request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(
730-
diagnosticNode,
731-
request.resourceType,
732-
request.operationType,
733-
0,
734-
options,
735-
);
729+
request.endpoint = await this.globalEndpointManager.resolveServiceEndpointInternal({
730+
diagnosticNode: diagnosticNode,
731+
resourceType: request.resourceType,
732+
operationType: request.operationType,
733+
startServiceEndpointIndex: 0,
734+
excludedLocations: options?.excludedLocations,
735+
});
736736
const response = await executePlugins(
737737
diagnosticNode,
738738
request,
@@ -840,13 +840,13 @@ export class ClientContext {
840840

841841
this.applySessionToken(request);
842842

843-
request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(
844-
diagnosticNode,
845-
request.resourceType,
846-
request.operationType,
847-
0,
848-
options,
849-
);
843+
request.endpoint = await this.globalEndpointManager.resolveServiceEndpointInternal({
844+
diagnosticNode: diagnosticNode,
845+
resourceType: request.resourceType,
846+
operationType: request.operationType,
847+
startServiceEndpointIndex: 0,
848+
excludedLocations: options?.excludedLocations,
849+
});
850850
const response = await executePlugins(
851851
diagnosticNode,
852852
request,
@@ -902,13 +902,13 @@ export class ClientContext {
902902
request.headers[HttpHeaders.BatchContinueOnError] = bulkOptions.continueOnError ?? true;
903903
this.applySessionToken(request);
904904

905-
request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(
906-
diagnosticNode,
907-
request.resourceType,
908-
request.operationType,
909-
0,
910-
options,
911-
);
905+
request.endpoint = await this.globalEndpointManager.resolveServiceEndpointInternal({
906+
diagnosticNode: diagnosticNode,
907+
resourceType: request.resourceType,
908+
operationType: request.operationType,
909+
startServiceEndpointIndex: 0,
910+
excludedLocations: options?.excludedLocations,
911+
});
912912
const response = await executePlugins(
913913
diagnosticNode,
914914
request,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
import type { ResourceType, OperationType } from "./common/index.js";
4+
import type { DiagnosticNodeInternal } from "./diagnostics/DiagnosticNodeInternal.js";
5+
6+
/**
7+
* @internal
8+
*/
9+
export interface ResolveServiceEndpointOptions {
10+
diagnosticNode: DiagnosticNodeInternal;
11+
resourceType: ResourceType;
12+
operationType: OperationType;
13+
/**
14+
* This is to indicate the starting index for selecting servers.
15+
*/
16+
startServiceEndpointIndex: number;
17+
/**
18+
* Excludes one or more Azure regions for the operation.
19+
* <p>This option is only applied when enableEndPointDiscovery is set to true.</p>
20+
*/
21+
excludedLocations?: string[];
22+
}

sdk/cosmosdb/cosmos/src/documents/ConnectionPolicy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ export interface ConnectionPolicy {
3030
/** Flag to enable/disable background refreshing of endpoints. Defaults to true.
3131
* Endpoint discovery using `enableEndpointsDiscovery` will still work for failed requests. */
3232
enableBackgroundEndpointRefreshing?: boolean;
33-
/** Flag to enable/disable the Per Partition Level Failover (PPAF). Defaults to false
34-
* If enablePartitionLevelFailover is set to true, by default enablePartitionLevelCircuitBreaker
35-
* will also be set to true. This is done to improve the read availability and latency.*/
33+
/** Flag to enable/disable the Per Partition Level Failover (PPAF).
34+
* Defaults to true. When enablePartitionLevelFailover set to true, enablePartitionLevelCircuitBreaker will also be set to true.
35+
* */
3636
enablePartitionLevelFailover?: boolean;
37-
/** Flag to enable/disable the Per Partition Level Circuit Breaker (PPCB). Defaults to false */
37+
/** Flag to enable/disable the Per Partition Level Circuit Breaker (PPCB). Defaults to true */
3838
enablePartitionLevelCircuitBreaker?: boolean;
3939
}
4040

sdk/cosmosdb/cosmos/src/documents/DatabaseAccount.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class DatabaseAccount {
7070
/**
7171
* Indicates whether per-partition failover behavior is enabled for the database account.
7272
*/
73-
public readonly enablePerPartitionFailoverBehavior: boolean = false;
73+
public readonly enablePerPartitionFailover: boolean = false;
7474

7575
// TODO: body - any
7676
public constructor(body: { [key: string]: any }, headers: CosmosHeaders) {
@@ -95,7 +95,7 @@ export class DatabaseAccount {
9595
this.enableMultipleWritableLocations = false;
9696
}
9797
if (body[Constants.ENABLE_PER_PARTITION_FAILOVER_BEHAVIOR]) {
98-
this.enablePerPartitionFailoverBehavior =
98+
this.enablePerPartitionFailover =
9999
body[Constants.ENABLE_PER_PARTITION_FAILOVER_BEHAVIOR] === true ||
100100
body[Constants.ENABLE_PER_PARTITION_FAILOVER_BEHAVIOR] === "true";
101101
}

0 commit comments

Comments
 (0)