Skip to content

Clear Azure subscription/auth cache on manual registries refresh#548

Draft
bwateratmsft with Copilot wants to merge 3 commits into
mainfrom
copilot/clear-auth-provider-cache
Draft

Clear Azure subscription/auth cache on manual registries refresh#548
bwateratmsft with Copilot wants to merge 3 commits into
mainfrom
copilot/clear-auth-provider-cache

Conversation

Copilot AI commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

The Azure registries view cached subscriptions and auth providers indefinitely, so subscription or sign-in changes weren't reflected without reloading the window. Following the pattern in microsoft/vscode-azureresourcegroups#1292, cache invalidation is now triggered by a user-initiated manual refresh.

Changes

  • AzureRegistryDataProvider: added clearCache(), which drops cached ACROAuthProvider instances and flags the next root load to bypass the subscription cache via getAvailableSubscriptions({ noCache }). The flag is consumed (reset) on that load.
  • RefreshManager: calls clearCache() only on manual registries refresh (reason === 'manual' && target === 'registries'), leaving programmatic/debounced refreshes untouched so routine operations don't incur extra token/subscription requests.
// AzureRegistryDataProvider.getChildren (root)
const noCache = this.clearCacheOnNextLoad;
this.clearCacheOnNextLoad = false;
const subscriptions = await this.subscriptionProvider.getAvailableSubscriptions({ noCache });
// RefreshManager.refresh, manual branch
if (target === 'registries') {
    ext.azureRegistryDataProvider.clearCache();
}

Per the azureauth v6 contract, noCache: true scopes to that single call and is the intended mechanism when an account's accessible subscriptions/tenants may have changed.

Copilot AI changed the title [WIP] Add method to clear subscription cache on manual refresh Clear Azure subscription/auth cache on manual registries refresh Jul 22, 2026
Copilot AI requested a review from bwateratmsft July 22, 2026 19:17
@bwateratmsft
bwateratmsft requested a review from Copilot July 23, 2026 14:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR ensures the Azure registries view reflects Azure account/subscription changes without requiring a VS Code window reload by invalidating Azure auth/subscription caches on user-initiated manual refresh of the Registries view.

Changes:

  • Added a clearCache() mechanism in AzureRegistryDataProvider to clear cached ACROAuthProvider instances and bypass the subscription cache on the next root load.
  • Updated RefreshManager to invoke clearCache() only for manual refreshes of the registries target.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
extensions/vscode-containers/src/tree/registries/Azure/AzureRegistryDataProvider.ts Adds cache invalidation plumbing and a one-shot noCache subscription load to reflect sign-in/subscription changes.
extensions/vscode-containers/src/tree/RefreshManager.ts Triggers Azure registries cache invalidation only on manual registries refresh.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

* subscriptions or signed-in accounts are reflected without needing to reload the window.
*/
public clearCache(): void {
this.authenticationProviders.clear();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Without having looked, is clearing the auth providers necessary or helpful?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot please check

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is necessary. authenticationProviders is keyed by registry URL only, not by subscription or account. If the user changes accounts or subscriptions, getAuthenticationProvider() would return a cached ACROAuthProvider still bound to the old AzureSubscription and its (potentially stale/revoked) credential. That provider also holds a cached ACR refresh token (refreshTokenCache) derived from the old credential, which would be invalid after an account change. Without clearing the map, any subsequent registry operation (listing tags, deleting images, etc.) would fail with auth errors until the window was reloaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auth v6: No way of clearing the subscription cache without reloading the window

3 participants