Skip to content

[Internal] Region Proximity: Adds logic to fetch and use server-provided region proximity data#5745

Draft
Meghana-Palaparthi wants to merge 4 commits intomainfrom
users/Meghana-Palaparthi/RegionProximityAPI
Draft

[Internal] Region Proximity: Adds logic to fetch and use server-provided region proximity data#5745
Meghana-Palaparthi wants to merge 4 commits intomainfrom
users/Meghana-Palaparthi/RegionProximityAPI

Conversation

@Meghana-Palaparthi
Copy link
Copy Markdown
Contributor

Pull Request Template

Description

This pull request introduces enhancements to Azure Cosmos DB's region proximity awareness and handling, allowing the SDK to better utilize the client's current region for improved geo-replicated account routing. The main improvements include tracking the client's current region, passing this information to the server, and updating preferred locations based on server-provided proximity data. Comprehensive unit tests have also been added to verify the new logic.

PR with spec document for migration from static table to server-provided region proximity : #5738

Type of change

Please delete options that are not relevant.

  • [] Bug fix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • [] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [] This change requires a documentation update

Closing issues

To automatically close an issue: closes #IssueNumber

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 1 pipeline(s).

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 1 pipeline(s).

string? region = token?.ToString();
if (!string.IsNullOrEmpty(region))
{
result.Add(region!);
Copy link
Copy Markdown
Contributor

@Praveen-Msft Praveen-Msft Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since these are string literals, do we need validate them against the actual region names? Also, Do we still need this file then? https://github.com/Azure/azure-cosmos-dotnet-v3/blob/master/Microsoft.Azure.Cosmos/src/Regions.cs

/// as set by <see cref="SetCurrentLocation"/>. Used to send region proximity hints
/// to the server during account discovery.
/// </summary>
internal string CurrentLocation { get; private set; }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CurrentRegion?

Comment on lines +45 to +55
if (!string.IsNullOrEmpty(this.connectionPolicy.CurrentLocation))
{
string sanitizedRegion = GatewayAccountReader.SanitizeRegionName(this.connectionPolicy.CurrentLocation);
if (!string.IsNullOrEmpty(sanitizedRegion))
{
serviceEndpoint = GatewayAccountReader.AppendQueryParameter(
serviceEndpoint,
Constants.RegionProximity.SourceRegionQueryParam,
sanitizedRegion);
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worth moving into its own method since its repeating in both endpoint manager and account reader

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants