Skip to content

Spec: Region discovery via IMDS /compute endpoint (#6039)#6044

Merged
Robbie-Microsoft merged 5 commits into
mainfrom
rginsburg/region-discovery-compute-spec
Jun 2, 2026
Merged

Spec: Region discovery via IMDS /compute endpoint (#6039)#6044
Robbie-Microsoft merged 5 commits into
mainfrom
rginsburg/region-discovery-compute-spec

Conversation

@Robbie-Microsoft

@Robbie-Microsoft Robbie-Microsoft commented May 29, 2026

Copy link
Copy Markdown
Contributor

Spec for #6039: migrate MSAL.NET region auto-discovery from the legacy IMDS text endpoint /metadata/instance/compute/location (api-version 2020-06-01, format=text) to the newer JSON endpoint /metadata/instance/compute (api-version 2021-02-01), parsing the location field.

What's in the spec

  • Overview, motivation, current vs. proposed behavior
  • Normative discovery order: REGION_NAME env var -> IMDS /compute JSON -> api-version probe on 400 -> fail
  • Request/response contract with sample JSON, validation rules
  • Caching, retry, timeouts, telemetry — all unchanged
  • Backward compatibility — no public API change
  • Test plan (12 scenarios) and non-normative implementation notes

Design decisions

  1. No kill-switch / feature flag. Consistent with prior IMDS changes; api-version probe self-heals.
  2. Drop format=text. New endpoint is JSON-native.
  3. No transitional fallback to /compute/location. Same host, same failure modes; clean cutover.
  4. Keep the api-version probe on 400. Unchanged.
  5. JSON parse / missing location -> FailedAutoDiscovery (matches today's empty-body behavior).
  6. Reuse existing ValidateRegion. No new validation rules.
  7. No telemetry schema change. Endpoint URL already flows into failure-reason via imdsUri.AbsoluteUri.

Scope

This PR is the spec only. Implementation will be a follow-up PR.

Spec for issue #6039: migrate RegionManager from /compute/location (text, api-version 2020-06-01) to /compute (JSON, api-version 2021-02-01). No public API change; env-var precedence, caching, retry, timeouts, telemetry, and fallback are all preserved.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 29, 2026 20:42
@Robbie-Microsoft Robbie-Microsoft requested a review from a team as a code owner May 29, 2026 20:42

Copilot AI left a comment

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.

Pull request overview

Adds a specification document describing how MSAL.NET should migrate region auto-discovery from the legacy IMDS text endpoint (/metadata/instance/compute/location) to the newer JSON IMDS /metadata/instance/compute endpoint and parse the location field, without introducing public API changes.

Changes:

  • Introduces a new spec covering motivation, discovery order, request/response contract, and API-version fallback behavior.
  • Documents caching/retry/timeout/telemetry expectations (intended to remain unchanged).
  • Provides a concrete test plan and non-normative implementation notes for the follow-up implementation PR.

Comment thread docs/region_discovery_imds_compute.md Outdated
Comment thread docs/region_discovery_imds_compute.md
Comment thread docs/region_discovery_imds_compute.md Outdated
Comment thread docs/region_discovery_imds_compute.md Outdated
Comment thread docs/region_discovery_imds_compute.md Outdated
…th claims

- Drop incorrect claim that IMDS body is normalized; only REGION_NAME env
  var is normalized today and this spec does not change that.
- Drop incorrect claim that RegionDiscoveryFailureReason includes the IMDS
  URL via imdsUri.AbsoluteUri; clarify the URL is not in the failure reason
  today and is intentionally out of scope (protects public TestConstants).
- Remove test row 11 (mixed-case/spaces normalization) since IMDS body is
  not normalized; renumber.
- Use full path for ClientCredentialWithRegionTests.cs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread docs/region_discovery_imds_compute.md
Captures the unified ImdsComputeSnapshot follow-up discussed with
@gladjohn and @neha-bhargava on PR #6044, with explicit out-of-scope
note for MI source detection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 1, 2026 18:21

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread docs/region_discovery_imds_compute.md
Comment thread docs/region_discovery_imds_compute.md
@Robbie-Microsoft Robbie-Microsoft enabled auto-merge (squash) June 1, 2026 18:31
Copilot AI review requested due to automatic review settings June 2, 2026 19:48

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread docs/region_discovery_imds_compute.md
@Robbie-Microsoft Robbie-Microsoft merged commit 9ed1a02 into main Jun 2, 2026
16 checks passed
@Robbie-Microsoft Robbie-Microsoft deleted the rginsburg/region-discovery-compute-spec branch June 2, 2026 20:17
@bgavrilMS

bgavrilMS commented Jun 9, 2026

Copy link
Copy Markdown
Member

@neha-bhargava - how should we consolidate all this logic? Like some helper MSAL API that has all this logic to avoid duplication?

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.

5 participants