-
Notifications
You must be signed in to change notification settings - Fork 33
Description
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.