Fix for azure subscriptions on multiple tenants not showing#20367
Closed
allancascante wants to merge 6 commits intomainfrom
Closed
Fix for azure subscriptions on multiple tenants not showing#20367allancascante wants to merge 6 commits intomainfrom
allancascante wants to merge 6 commits intomainfrom
Conversation
12 tasks
12 tasks
PR Changes
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #20367 +/- ##
==========================================
+ Coverage 54.94% 55.14% +0.19%
==========================================
Files 200 200
Lines 17460 17466 +6
Branches 1142 1141 -1
==========================================
+ Hits 9593 9631 +38
+ Misses 7867 7835 -32
🚀 New features to boost your workflow:
|
12 tasks
Benjin
reviewed
Oct 29, 2025
Benjin
reviewed
Oct 29, 2025
Benjin
reviewed
Oct 29, 2025
Benjin
requested changes
Nov 7, 2025
Contributor
Benjin
left a comment
There was a problem hiding this comment.
Let's chat about this PR and the proposed fixes after Ignite.
Contributor
|
This was completed in another PR |
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.
Description
When a user has access to the same Azure subscription through multiple accounts (e.g., personal and work accounts), the subscription filter dialog exhibited several issues, reported here:
Duplicate Selection Bug: Selecting one instance of a subscription would automatically select all instances across different accounts
Missing Subscriptions: Not all subscriptions were visible in the filter dropdown, even when no filtering was applied
Missing Tenants: Not all tenants for an account were displayed in the connection dialog
Error on Load: "Error loading Azure subscriptions" appeared when the same subscription existed under multiple accounts
Root Cause Analysis
Issue 1: Tenant Discovery
Problem: auth.getTenants(account) with an account parameter wasn't reliably returning all tenants for an account, particularly for newly added tenants where the user hadn't explicitly signed in through VS Code.
Fix: Changed from auth.getTenants(account) to auth.getTenants() (without account parameter) to fetch ALL tenants across all accounts, then filter by account ID client-side. This ensures all tenants are discovered regardless of authentication state.
Issue 2: Token Refresh
Problem: VS Code's Azure authentication system only returns subscriptions from tenants where it has active authentication tokens. Newly added tenants/subscriptions weren't discovered until explicit authentication.
Fix: Added refreshAzureTokensForAllAccounts() method that proactively signs into all tenants for all accounts when the connection dialog opens, ensuring all subscriptions are discoverable.
Issue 3: Subscription Storage Collisions
Problem: The subscription filter used a composite key format tenantId/subscriptionId, which is not unique when the same subscription is accessible from multiple accounts. This caused:
Fix: Changed composite key format from tenantId/subscriptionId to account/tenantId/subscriptionId to ensure uniqueness. Updated all related code:
Changes Made
Core Logic Changes
Testing
New Test File: MssqlVSCodeAzureSubscriptionProvider.test.ts:
Enhanced Test File: azureHelpers.test.ts:
UI Updates
Before:
After:
Breaking Changes
Configuration Format Change: Existing subscription filters stored as tenantId/subscriptionId will need to be reset. Users with active filters will see all subscriptions unfiltered on first use after update and will need to re-select their desired subscriptions. This is intentional to avoid migration complexity and ensure clean state.
The change maintains backward compatibility with the VS Code Azure SDK and doesn't affect users who:
Code Changes Checklist
npm run test)Reviewers: Please read our reviewer guidelines