Skip to content

Caching issues with EntraID credentials #388

@j0nahm

Description

@j0nahm

Is your feature request related to a problem? Please describe.

Yes, I am experiencing ~1s latency per connection when using Authentication=ActiveDirectoryDefault with AzureCliCredential (in a FastAPI app).

The mssql-python driver instantiates a new DefaultAzureCredential object for every new connect() call. Since the Azure CLI credential in the azure-identity library does not provide token caching, this triggers a slow az subprocess call for every single database request, creating a massive performance bottleneck.

Describe the solution you'd like

The driver should implement its own token caching mechanism.

Describe alternatives you've considered

I've considered passing my own token using attrs_before, but this would require developing my own token cache. I think it makes more sense for the DB driver to handle the caching.

Additional context

The redis-py-entraid library avoids this issue by implementing its own token caching layer.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesttriage neededFor new issues, not triaged yet.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions