Add cluster recommendations API support to SDKs#653
Merged
Conversation
Add the cluster recommendations API across the C#, TypeScript, and Go SDKs so tunnel creation can auto-select an optimal cluster when none is specified. Contracts (C# source-of-truth, auto-generated to TS/Go/Java/Rust): - ClusterAvailability, ClusterRecommendation, ClusterRecommendationResponse - Generator: add float/double type mappings (TS/Go/Java/Rust writers) Management clients: - GetClusterRecommendations(Async) in C#, TS, Go (preferredClusterId, requiredGeo) - Auto-recommend in CreateTunnel (C#, TS, Go) when ClusterId is unset; errors fall back to global routing - RequiredGeo on TunnelRequestOptions (C#, TS, Go) forwarded to the auto-recommend call only (excluded from the create request query string) Tests: unit coverage for recommendations, auto-recommend, geo forwarding, and skip-when-cluster-set across C#, TS, and Go. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
adamasmar
approved these changes
Jun 19, 2026
plequere-ms
approved these changes
Jun 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for the new tunnels Cluster Recommendations API across the C#, TypeScript, and Go SDKs (with generated contracts for Java and Rust). The SDK can now automatically select the best cluster for a new tunnel, optionally constrained by a required geography, while remaining fully backward compatible.
Contracts (C# source-of-truth, auto-generated to TS/Go/Java/Rust):
What changed
GetClusterRecommendations(preferredClusterId, requiredGeo)(C#/TS/Go, plus interface + mocks) returns ranked cluster recommendations.CreateTunnelnow, when no cluster is specified, calls the recommendations API and creates the tunnel in the recommended cluster. Any failure is swallowed and the call falls back to normal global (Traffic Manager) routing. If a cluster is already set, the recommendations call is skipped.RequiredGeorequest option — added toTunnelRequestOptionsin all three SDKs. It is forwarded only on the recommendations request and is intentionally excluded from the create-tunnel query string.ClusterAvailability,ClusterRecommendation,ClusterRecommendationResponse(generated for all languages from the C# source).Notable fix
buildUrialiasing bug —buildUrimutated the sharedm.uri(*url.URL) in place. Latent before, but auto-recommend now setsClusterID, which made the base URI get permanently pinned to the recommended cluster's host for all subsequent requests. Fixed by copying the URL by value; added a dedicated regression test.Testing
CreateTunnelsuite passing (incl. new parity + regression tests covering: recommend-when-unset, skip-when-set,RequiredGeoforwarding,RequiredGeoexcluded from create, and no base-URI mutation)./clusters/recommendationsGET first, creates the tunnel in the returned cluster, and deletes it;RequiredGeorides the recommendations request and is absent from the create request.Pre-PR checklist
PackageVersionbumped0.1.26→0.1.27ingo/tunnels/tunnels.go(per the patch-per-PR convention).connectionsandmanagementalready require@microsoft/dev-tunnels-contracts/-managementat>1.3.50, which is greater than the current published1.3.48. (CI rewrites these to concrete versions at publish time.) No change needed.Compatibility
Fully backward compatible. Existing callers that set a cluster, or that don't, behave exactly as before — the only new behavior is automatic cluster selection when none is provided, with graceful fallback on any error.