Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
allancascante wants to merge6 commits intomain
base:main
Choose a base branch
Loading
fromdev/allancascante/fix_subscription_listing_multiple_tenants

Conversation

@allancascante
Copy link
Contributor

@allancascanteallancascante commentedOct 28, 2025
edited
Loading

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, reportedhere:

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:

  • Subscriptions stored in a Map<subscriptionId, AzureSubscription> to overwrite each other
  • Filter configuration to store duplicate entries
  • UI to show both instances as selected when only one was chosen

Fix: Changed composite key format from tenantId/subscriptionId to account/tenantId/subscriptionId to ensure uniqueness. Updated all related code:

  • Subscription Map storage
  • Filter configuration format
  • getTenantFilters() and getSubscriptionFilters() parsing logic
  • Tenant ID population in subscription info

Changes Made

Core Logic Changes

  1. azureHelpers.ts
  • Modified getTenantsForAccount() to fetch all tenants then filter by account
  • Updated composite key generation: ${sub.account.label}/${sub.tenantId}/${sub.subscriptionId}
  • Updated promptForAzureSubscriptionFilter() to use new composite key format
  • Enhanced getSubscriptionQuickPickItems() to include account label in description for disambiguation
  1. connectionDialogWebviewController.ts
  • Added refreshAzureTokensForAllAccounts() method to proactively ensure tokens exist for all tenants
  • Modified loadAzureSubscriptions() to call token refresh before fetching subscriptions
  • Updated subscription Map key from subscriptionId to ${tenantId}/${subscriptionId}
  • Updated loadAzureServersForSubscription() to accept both tenantId and subscriptionId parameters
  • Modified reducer to extract tenantId from state when loading servers
  • Added tenant count to telemetry for tracking scenario where users have multiple tenants
  1. MssqlVSCodeAzureSubscriptionProvider.ts
  • Updated getTenantFilters() to parse index 1 from 3-part composite key
  • Updated getSubscriptionFilters() to parse index 2 from 3-part composite key
  1. connectionDialog.ts
  • Added tenantId: string field to AzureSubscriptionInfo interface
  1. azureBrowsePage.tsx
  • Changed server selection mode from SelectFirstIfAny to AlwaysSelectNone (prevents auto-selection)
  • Added proper cleanup of database selection when server selection becomes invalid

Testing

New Test File: MssqlVSCodeAzureSubscriptionProvider.test.ts:

  • getTenantFilters extracts tenant IDs from composite keys
  • getSubscriptionFilters extracts subscription IDs from composite keys
  • getTenantFilters handles empty configuration
  • getSubscriptionFilters handles empty configuration
  • filters correctly handle duplicate subscriptions from different accounts
  • filters correctly parse complex email addresses

Enhanced Test File: azureHelpers.test.ts:

  • creates pick items with account-based composite keys
  • respects previous selection with account-based composite keys
  • handles complex email addresses in composite keys

UI Updates

Before:

  • Subscription filter showed duplicate selections for shared subscriptions:
imageimage
  • Not all subscriptions visible even without filters
  • Auto-selected servers inappropriately
  • Error messages when loading subscriptions

After:

  • Each subscription+account combination is independently selectable
image- All subscriptions from all tenants are discoverable on dialog openimage- Subscription filter accurately reflects user selection- No auto-selection of servers/databases unless explicitly chosen- Clear visual distinction in UI showing account email in subscription description

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:

  • Only have one Azure account
  • Don't have duplicate subscriptions across accounts
  • Haven't set up subscription filters
  • Related: This fix also resolves the server auto-selection issue mentioned in the original report where servers were being selected even when filters weren't specified.

Code Changes Checklist

  • New or updatedunit tests added
  • All existing tests pass (npm run test)
  • Code followscontributing guidelines
  • Telemetry/logging updated if relevant
  • No regressions or UX breakage

Reviewers:Please read our reviewer guidelines

@github-actions
Copy link

github-actionsbot commentedOct 28, 2025
edited
Loading

PR Changes

CategoryTarget BranchPR BranchDifference
Code Coverage57.07%57.14%⚪ 0.00%
VSIX Size4911 KB4898 KB⚪ -13 KB ( 0% )
Webview Bundle Size4032 KB4024 KB⚪ -8 KB ( 0% )

@codecov-commenter
Copy link

codecov-commenter commentedOct 28, 2025
edited
Loading

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.14%. Comparing base (3b09699) to head (75d7a88).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            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
Files with missing linesCoverage Δ
src/azure/MssqlVSCodeAzureSubscriptionProvider.ts100.00% <100.00%> (+73.33%)⬆️
src/connectionconfig/azureHelpers.ts68.23% <100.00%> (+11.68%)⬆️
...nectionconfig/connectionDialogWebviewController.ts47.28% <100.00%> (+0.60%)⬆️
src/sharedInterfaces/connectionDialog.ts95.45% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@allancascanteallancascante linked an issueOct 29, 2025 that may beclosed by this pull request
12 tasks
Copy link
Contributor

@BenjinBenjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Let's chat about this PR and the proposed fixes after Ignite.

@BenjinBenjin marked this pull request as draftNovember 11, 2025 02:18
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@BenjinBenjinBenjin requested changes

@kburtramkburtramAwaiting requested review from kburtramkburtram is a code owner

@aasimkhan30aasimkhan30Awaiting requested review from aasimkhan30aasimkhan30 is a code owner

@caohaicaohaiAwaiting requested review from caohaicaohai is a code owner

@laurenastrid1laurenastrid1Awaiting requested review from laurenastrid1laurenastrid1 is a code owner

@lewis-sanchezlewis-sanchezAwaiting requested review from lewis-sanchezlewis-sanchez is a code owner

@ssreeramassreeramaAwaiting requested review from ssreeramassreerama is a code owner

@manujoseph85manujoseph85Awaiting requested review from manujoseph85manujoseph85 is a code owner

Requested changes must be addressed to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Bug]: Unable to list subscription from several tenants

4 participants

@allancascante@codecov-commenter@Benjin

[8]ページ先頭

©2009-2025 Movatter.jp