Repository navigation
Description
Summary
Upgrade @microsoft/vscode-azext-azureauth from 4.1.1 to v6. This has three reasons:
- ES module build. Removes the
@azure/arm-resources-subscriptionsVite alias that Modernize the build, bundling, and test stack #880 added (original scope of this issue, details below). - Subscription loading is slow and repeated. 4.1.1 has no cache and lists every account × tenant one after another, on every call. v6 is a rewrite that adds caching, parallel listing, a public per-tenant lookup and cancellation.
- Deep links to Azure resources (Open Azure resources and the dashboard or shell from deep links (/connect/azure, open=) #1067) spend most of their time listing subscriptions. Part of that work in Open Azure resources and the dashboard or shell from deep links (/connect/azure, open=) #1067 was deferred to this upgrade (see Deep links below).
Blockers: #880 is merged. Start after #1067 is merged, because it adds new subscription call sites (src/deepLinks/azureSubscription.ts) that this upgrade must migrate.
Why subscription loading is slow today (measured)
From a /connect/azure trace in #1067:
15:25:03.256 Looking up the subscription node ← 10.7 s: getSubscriptions() across all accounts × tenants
15:25:13.960 Looking up the cluster node ← 4.4 s: databaseAccounts.list (RU)
VSCodeAzureSubscriptionProvider.getSubscriptions()(4.1.1) doesfor account → await getTenants(account) → for tenant → await getSubscriptionsForTenant(…), plus each account's home tenant. Every call does the full walk. There is no cache, and nothing runs in parallel.- The filter is applied after the full listing, so
getSubscriptions(true)costs as much asgetSubscriptions(false). - Each discovery plugin has its own provider instance (
azure-mongo-vcore-discovery,azure-mongo-ru-discovery,azure-vm-discovery), so expanding all three lists three times. - A
/connect/azuredeep link lists twice: once inresolveAzureSubscription(unfiltered, to find the account and tenant) and again when the Discovery view's provider root expands (filtered). getSubscriptionsForTenantis private in 4.1.1, so there is no public way to load one tenant except thegetSubscriptions({ tenantId })filter.
What v6 offers (checked against 6.1.0-alpha.2)
| 4.1.1 (today) | v6 | |
|---|---|---|
| Listing | sequential, full walk on every call | cached (before filtering), parallel with a limiter |
| Cache control | — | noCache per call; automatic partial refill after sign-in; onRefreshSuggested (sessionChange, subscriptionFilterChange, cloudChange) |
| Per-tenant lookup | private | public getSubscriptionsForTenant({ tenantId, account }) |
| Failing tenant | aborts the listing | skipped |
| Cancellation | none | CancellationToken on every call |
| Sovereign cloud change | — | watched, fires cloudChange |
| Step-up MFA | — | BearerChallengePolicy |
v6 still has no "get subscription by ID". Loading a subscription still needs its tenant (see Deep links).
Breaking API changes to plan for (4.1.1 → v6)
getSubscriptions(filter)→getAvailableSubscriptions(options)getTenants(account?)→getAccounts()+getTenantsForAccount(account), plusgetUnauthenticatedTenantsForAccountisSignedIn(tenantId?, account?)→ removed; usegetAccounts()/signIn(tenant, { promptIfNeeded: false })signIn(tenantId?, account?)→signIn({ tenantId, account }?, options?)onDidSignIn/onDidSignOut→onRefreshSuggested- Providers moved to
providers/, with a newAzureSubscriptionProviderBase. Protected hooks still exist:getSubscriptionFilters,getTenantFilters,getAccountFilters. - Also read the intermediate 4.2.0 / 5.0.0 / 5.1.0 entries in the package
CHANGELOG.md(auth challenges, CJS+ESM,onDidChangeSessionsonly subscribed when events are used).
Call sites (on the #1067 branch; re-check after merge)
| File | Uses |
|---|---|
src/plugins/api-shared/azure/AzureSubscriptionProviderWithFilters.ts |
subclass; overrides getSubscriptionFilters (reads azureResourceGroups.selectedSubscriptions, globalState fallback azure-discovery.selectedSubscriptions) |
src/plugins/service-azure-mongo-vcore/discovery-tree/AzureServiceRootItem.ts |
isSignedIn, getSubscriptions(true) |
src/plugins/service-azure-mongo-ru/discovery-tree/AzureMongoRUServiceRootItem.ts |
same |
src/plugins/service-azure-vm/discovery-tree/AzureServiceRootItem.ts |
same |
src/plugins/api-shared/azure/wizard/SelectSubscriptionStep.ts |
getSubscriptions(false) |
src/plugins/api-shared/azure/subscriptionFiltering/InitializeFilteringStep.ts |
getTenants, isSignedIn(tenant, account), getSubscriptions(false) |
src/plugins/api-shared/azure/credentialsManagement/SelectAccountStep.ts, AccountTenantsStep.ts |
getTenants, isSignedIn, signIn |
src/commands/newConnection/PromptTenantStep.ts, src/commands/updateCredentials/PromptTenantStep.ts |
isSignedIn, getTenants (wrapped in traceTenantLookup) |
src/deepLinks/azureSubscription.ts (#1067) |
isSignedIn, signIn, signIn(tenantId), getSubscriptions(false) |
src/documentdb/auth/documentdbTokenResource.ts |
getConfiguredAuthProviderId, getConfiguredAzureEnv (still exported in v6 from utils/configuredAzureEnv) |
About 15 more files under src/plugins/api-shared/azure/ and src/plugins/service-azure-* import types only (AzureTenant, AzureSubscription, …).
Things to pay attention to
Version and bundle
- Dedupe:
@microsoft/vscode-azext-azureutils4.2.0 depends on^6.0.0-alpha.6and installs6.0.0-alpha.8. That range accepts6.0.0-alpha.8but not6.1.0-alpha.2(prerelease ranges don't cross minor versions; checked withsemver). Picking6.1.0-alpha.2keeps two auth copies in the bundle. Pick6.0.0-alpha.8, or bumpazureutilsto a version that accepts 6.1.x. - v6 is still alpha (first alpha 2025-12, latest
6.1.0-alpha.22026-06). The Azure Resources extension ships on^6.1.0-alpha.2; vscode-cosmosdb is on~5.1.1. 5.1.1 gives only the ESM build, none of the loading improvements. engines.vscode: v6 needs^1.106.0; we require^1.109.0.- Dependency quarantine: no version published in the last 7 days (
node .github/skills/flagging-fresh-dependencies/scripts/find-fresh-dependencies.mjs --fail-on-fresh). - l10n:
l10n/scripts/constants.mjsmerges a checked-in copy of the package's bundle atl10n/@microsoft/vscode-azext-azureauth/bundle.l10n.json. Refresh it from the new version, thennpm run l10nandnpm run l10n:check.
Filters and caching
- v6 caches before filtering, so filter changes take effect without
noCache. Check that ourgetSubscriptionFiltersoverride, with its globalState fallback, is still called on every listing and thatsubscriptionFilterChangefires for our writes. - Our tenant filter is ours, stored in globalState (
subscriptionFilteringHelpers.ts), and applied by callers throughgetTenantFilteredSubscriptions. v6 has agetTenantFiltershook. Decide whether to keep our filter as is or map it onto the hook; don't do both. - Open Azure resources and the dashboard or shell from deep links (/connect/azure, open=) #1067 writes filters from a deep link (D0011):
showDiscoveryProvider,removeUnselectedTenant,setSelectedSubscriptionIds. After the upgrade, the Discovery view must show the newly selected subscription without a manual refresh. - One provider instance per plugin means one cache per plugin. Consider sharing one provider instance across the vCore, RU and VM plugins so they share a cache. Mind disposal: today each plugin disposes its own provider.
- Use
noCache: truewherever a stale list is wrong: the explicit Refresh on Discovery provider roots, and the deep link's retry after "subscription not found" (the user may just have been granted access). - The root items carry a comment that running
getSubscriptionsandgetTenantsin parallel once gave wrong results. Re-check that note with v6's own parallel listing, and drop it if it no longer applies.
Sign-in and events
isSignedInis gone. Every "Sign in to Azure" prompt (discovery roots, wizards, deep link) needs a new check that doesn't prompt (signIn(…, { promptIfNeeded: false })orgetAccounts()).- Session changes: verify sign-out, sign-in and account switch refresh the Discovery view (
onRefreshSuggested), and that cachedAzureSubscription.credentialobjects from a signed-out session are not reused. - Sovereign clouds (
docs/ai-and-plans/features/sovereign-clouds/): v6 watches the cloud setting. Check that switching clouds clears the cache and refreshes. - "Skip failing tenants": a tenant that needs re-authentication now silently drops its subscriptions instead of failing. Check that the Discovery view and the deep link's tenant sign-in offer still guide the user.
Deep links (#1067)
resolveAzureSubscription lists every subscription to find the account and tenant of one subscription ID. After the upgrade:
- Find the tenant first: the link's
tenantIdwhen present; otherwise the anonymous ARM challenge. An unauthenticatedGET https://<ARM endpoint>/subscriptions/{id}?api-version=2022-12-01returns401withWWW-Authenticate: Bearer authorization_uri="https://login.windows.net/<tenantId>"(verified). Use the configured cloud's ARM endpoint. Keep the full listing as a fallback. - Load only that tenant:
getSubscriptionsForTenant({ tenantId, account })for each account fromgetAccounts(). Keep the existing rules: prefer an account whose tenant is not filtered out; offer "Sign in to tenant" when no account has it (now also possible withouttenantIdin the link). - Cancellation: pass the progress notification's
CancellationToken(the/connect/azurenotification is already cancellable) so ✕ aborts the listing instead of only stopping between steps. - With the cache, the Discovery view's "Loading subscriptions…" step after the link (Open Azure resources and the dashboard or shell from deep links (/connect/azure, open=) #1067 walks the tree through the view) should be served from the cache instead of listing again.
Expected: the first step of an Azure deep link goes from ~10 s to ~1–2 s, and the tree step becomes a cache hit.
Original scope (from #880): remove the bundler workaround
vite.config.ext.mjsaliases@azure/arm-resources-subscriptionsto its CommonJS entry (TODO(#990)). 4.1.1'sPromise.resolve().then(() => require('@azure/arm-resources-subscriptions'))is bundled by Rolldown to a promise that resolves toundefined(G5-I01 indocs/ai-and-plans/modernization/build-and-test-stack.md). Remove the alias, its comment and theTODO.test/vitest/setup.tshooksrequire('vscode')for CommonJS azext packages (review finding S2-F03). Check whether the hook can go, or record which CommonJS dependency still needs it.
How to verify
npm run build,npm run lint,npm run typecheck:tests,npx vitest run,npm run l10n:check.npm run package,npm run verify:vsix -- <vsix>,npm run prove:vsix -- <vsix>, L3 (npm run test:vsix -- <vsix>).- Bundle scan: no
Promise.resolve().then(() => X())left whereXis an__esmMininitialiser (G5-I01), and only one copy ofvscode-azext-azureauthin the bundle. - Manual, on the installed VSIX:
- first sign-in; Azure vCore, RU and VM discovery; expanding all three (one listing, not three);
- the tenant and subscription filter wizard; the subscription filter shared with Azure Resources;
- new connection and update credentials through Azure (
PromptTenantSteps); - sign-out, sign-in, account switch, a second tenant needing sign-in, MFA step-up;
- a sovereign cloud switch;
- the Azure Resources view's DocumentDB nodes (dashboard, Collection View, Document View);
/connect/azuredeep links (vCore and RU; with and withouttenantId; hidden subscription, tenant or provider; cancelling the progress notification). The trace log ([DeepLink]lines) shows each step's timing.
References
- Modernize the build, bundling, and test stack #880: build and test stack modernization (G5-I01, S2-F03).
- Open Azure resources and the dashboard or shell from deep links (/connect/azure, open=) #1067:
/connect/azuredeep links,docs/ai-and-plans/features/deep-links/(D0008–D0017; theresolveAzureSubscriptionand view-walk notes). - Upstream: microsoft/vscode-azuretools#2092 (CJS+ESM), microsoft/vscode-azuretools#2119 (v6 rewrite: caching, parallelization, filtering), microsoft/vscode-azuretools#2208 (skip failing tenants), microsoft/vscode-azuretools#2231 (BearerChallengePolicy), microsoft/vscode-azuretools#2248 (cloud config watch).
Activity
S5: record the G5-I01 decision, fix and follow-up issue #990
S8: pin Vitest pool and isolation and test the vscode mock identity
[-]Upgrade @microsoft/vscode-azext-azureauth to its ES module build and remove the arm-resources-subscriptions alias (after #880)[/-][+]Upgrade @microsoft/vscode-azext-azureauth to v6: ES module build, cached and faster subscription loading[/+]