Skip to content

Add support for MSAL Token Cache persistence with Azure authentication #1895

Description

@cheenamalhotra

Presently, ActiveDirectoryAuthenticationProvider implements all authentication modes but MSAL Cache location is not customizable and is in-memory by default. Cache persistence is useful for system apps that want to cache access token to file system using MSAL/Azure.Identity's cache options.

Proposed solution:

Expose API/type to enable cache persistence in OS with user options, such as:

  • Cache file name
  • Cache file location
  • Cache encryption (enabled/disabled)
  • Cache Key format
    and so on..

These options can be extended based on what underlying libraries support, and most common options can be supported. Because underlying libraries are not same for all auth modes, exposing a SqlClient specific API will ensure this support continues to be available across all authentication modes that support silent authentication.

Alternatives

The only alternative solution as of now is to implement the SqlAuthenticationProvider abstract class to be able to customize cache location and enable persistence.

I still need to solidify API design proposal but putting out this feature request to exchange thoughts :)

Activity

  1. lcheunglci commented on Jan 24, 2023

    @lcheunglci
    Contributor

    Thanks @cheenamalhotra for the suggestion

  2. moved this from To triage to Backlog in SqlClient Boardon Dec 23, 2025
  3. priyankatiwari08 commented on Sep 17, 2026

    @priyankatiwari08
    Contributor

    /triage

  4. github-actions commented on Sep 17, 2026

    @github-actions

    🔍 Triage Summary (on-demand re-triage)

    Check Result
    Issue type Feature
    Environment Not applicable (feature request, not a bug)
    Area Area\Azure Connectivity
    Duplicates None found (no open issue specifically requests MSAL/Azure.Identity token cache persistence to disk; related but distinct closed issues exist around AAD token refresh/expiry, e.g. #989 "Authentication provider for 'Active Directory Interactive' should maintain access token cache globally")
    Regression Not indicated (feature request, no prior working behavior claimed)

    Analysis

    This is a feature request to expose configurable MSAL/Azure.Identity token cache persistence (file location, name, encryption, key format) for ActiveDirectoryAuthenticationProvider, which currently only supports an in-memory cache. This affects all Azure AD authentication modes that route through MSAL/Azure.Identity silent auth (e.g. ActiveDirectoryIntegrated, ActiveDirectoryServicePrincipal, ActiveDirectoryManagedIdentity, ActiveDirectoryDefault). It would primarily touch ActiveDirectoryAuthenticationProvider.cs and potentially require new connection string keywords or a new public API surface (requiring ref/ updates per API design guidelines). Severity/priority: P3 (enhancement, no functional break, but would reduce repeated token acquisition/auth server round-trips for long-running system apps).

    Next Steps

    • API design work is needed before implementation: decide whether persistence options are exposed via new connection string keywords, a new SqlAuthenticationProviderConfiguration-style options object, or by documenting the existing SqlAuthenticationProvider extensibility point as the supported workaround (noted by the reporter as the current alternative).
    • Recommend a maintainer (e.g. @cheenamalhotra, who filed this) confirm current priority and whether this is still desired, since the issue has been open since Jan 2023 with only one acknowledgment comment.
    • If greenlit, an implementation plan should cover: cache file naming, location, encryption, and key format options, using MSAL's Microsoft.Identity.Client.Extensions.Msal cache persistence APIs (already a common pattern for Azure.Identity/MSAL cross-platform token caching) and add corresponding tests plus doc/samples/ examples.
    • No duplicates require closing at this time.

    Note: This triage summary is auto-generated by an AI agent. The analysis and suggestions above have not been verified by a human maintainer. Please treat as preliminary guidance only.

    Generated by SqlClient Issue Auto-Triage for #1895 · copilot · auto · 47.9 AIC · ⌖ 13.1 AIC · ⊞ 11.9K · ◷

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions