Support AccessToken in config for AddDistributedSqlServerCache
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is your feature request related to a problem? Please describe.
I'm trying to setup Distributed SQL Caching so that is uses an AccessToken to connect to an Azure SQL database instead of using other types of credentials.
### Describe the solution you'd like
Now that Net Core 2.2 supports the AccessToken property on a SqlConnection, the AddDistributedSqlServerCache extension should be modified to support this as well. Perhaps an overload could be added that takes in a delegate to retrieve an AccessToken. The delegate would just need to be a simple factory method that does something like this:
var tokenProvider = new AzureServiceTokenProvider();
var accessToken = tokenProvider.GetAccessTokenAsync("https://database.windows.net/").Result;
In a web environment, the factory should be scoped to the session.
Or perhaps even build this AccessToken retrieval into the extension.
### Describe alternatives you've considered
I've considered writing my own implementation of IDistributedCache that takes advantage of the AccessToken property but I'm not quite sure how to accomplish it and I don't have the time right now. At the moment, I'm just using the classic implementation of the extension which passes in a connection string that is transformed between environments in an Azure Devops pipeline.
### Additional context
Contributor guide
Assessment
This issue has not been assessed yet.