-
Notifications
You must be signed in to change notification settings - Fork 541
Fix for azure subscriptions on multiple tenants not showing #20367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
allancascante
wants to merge
6
commits into
main
Choose a base branch
from
dev/allancascante/fix_subscription_listing_multiple_tenants
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix for azure subscriptions on multiple tenants not showing #20367
allancascante
wants to merge
6
commits into
main
from
dev/allancascante/fix_subscription_listing_multiple_tenants
Conversation
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
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
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