Repository navigation
Add COSMIC_LOCATION to region auto-detection - #6240
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 813d151a-7ed9-46c3-87ba-689f6ff9e23c
Contributor
There was a problem hiding this comment.
π’ Approval recommended
No active review issues remain for the environment-based region discovery change.
No open issues π
What changed in this PR
Adds COSMIC_LOCATION as an environment-based region discovery source in MSAL.NET, avoiding an IMDS request when it provides a valid region.
Changes:
- Preserves discovery precedence:
REGION_NAME, thenCOSMIC_LOCATION, then IMDS, using existing normalization and validation. - Adds tests for precedence, invalid-value fallback, explicit-region behavior, and opt-in discovery.
- Extends telemetry acceptance coverage to both environment variables, including cached discovery.
Review limitation: base-branch provenance of the loaded repository guidance was not verified.
| File | Description |
|---|---|
| tests/βMicrosoft.Identity.Test.Unit/βTelemetryTests/βRegionalTelemetryTests.cs | Runs telemetry acceptance tests with either environment source. |
| tests/βMicrosoft.Identity.Test.Unit/βCoreTests/βRegionDiscoveryProviderTests.cs | Adds COSMIC discovery coverage and environment isolation. |
| src/βclient/βMicrosoft.Identity.Client/βInstance/βRegion/βRegionManager.cs | Checks COSMIC_LOCATION after unusable REGION_NAME and before IMDS. |
Review effort: Balanced
Bogdan Gavril (bgavrilMS)
approved these changes
Oct 27, 2026
Gladwin Johnson VR (gladjohn)
approved these changes
Oct 27, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 813d151a-7ed9-46c3-87ba-689f6ff9e23c
Robbie-Microsoft
approved these changes
Oct 27, 2026
This was referenced Oct 29, 2026
Closed
Merged
This was referenced Nov 12, 2026
Merged
maksii
pushed a commit
to maksii/paqvilo
that referenced
this pull request
Nov 16, 2026
Updated [Microsoft.Identity.Client](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet) from 4.91.1 to 4.92.0. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Identity.Client's releases](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/releases)._ ## 4.92.0 ### New Features - Added `COSMIC_LOCATION` as a regional auto-detection source, after `REGION_NAME` and before IMDS. [#β6240](AzureAD/microsoft-authentication-library-for-dotnet#6240) - Added `ITokenCacheSnapshotProvider` and `TokenCacheSnapshot` for process-local token-cache capture and restore without repeated JSON serialization. Use V3 serialization for persistence. [#β6229](AzureAD/microsoft-authentication-library-for-dotnet#6229) ### Bug Fixes - Fixed certificate private-key attachment on .NET Framework 4.7.2 to support non-exportable CNG keys. [#β6244](AzureAD/microsoft-authentication-library-for-dotnet#6244) - Fixed managed identity KeyGuard attestation endpoint selection to use cloud-specific regional endpoints from IMDS compute metadata. [#β6238](AzureAD/microsoft-authentication-library-for-dotnet#6238) - Fixed Android broker request serialization by registering `BrokerRequest` in the source-generated JSON serializer context. [#β6226](AzureAD/microsoft-authentication-library-for-dotnet#6226) ### Changes - Updated `Microsoft.Identity.Client.NativeInterop` from 0.20.6 to 0.20.7. [#β6230](AzureAD/microsoft-authentication-library-for-dotnet#6230) - Reduced OpenTelemetry metric-tag allocations using `TagList` and cached canonical tag-key sets. Custom enrichers should use noncanonical tag names. [#β6227](AzureAD/microsoft-authentication-library-for-dotnet#6227) Commits viewable in [compare view](AzureAD/microsoft-authentication-library-for-dotnet@4.91.1...4.92.0). </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This was referenced Nov 16, 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.
Issue: n/a (requested enhancement).
Changes proposed in this request
Add
COSMIC_LOCATIONas a region auto-detection source before contacting IMDS.REGION_NAME, thenCOSMIC_LOCATION, then IMDS.EnvVariabletelemetry.Testing
Tests cover source precedence, normalization, missing/empty/invalid values falling back to IMDS, explicit-region precedence, auto-detection remaining opt-in, and end-to-end regional token requests with environment-source and cached-source telemetry.
Validated with .NET SDK 8.0.418:
Passed: 103 tests, 0 failed, 0 skipped. The command built the affected product and test projects with warnings treated as errors.
Passed.
Passed.
Integration tests and .NET Framework tests were not run.
Performance impact
Avoids an IMDS network request when
COSMIC_LOCATIONprovides a valid region andREGION_NAMEdoes not. Existing discovery caching is unchanged. No performance benchmarks were run.Documentation
Reference: COSMIC environment variables. The link is included in source; its contents require authenticated access and were not independently verified.
assistance: agentic-cli
type: feature
agent-tool: copilot-cli
agent-model: gpt-6.1-sol
work-item: AB#n/a