SqlConnection should support Azure AD token-based authentication
The desktop .NET Framework 4.6 and newer has an AccessToken property on the SqlConnection class (MSDN) which can be used to authenticate to a SQL Azure database using an access token issued by Azure AD (examples here). However, this property is not present on the version of SqlConnection provided in the System.Data.SqlClient NuGet package, including the latest preview v4.3.0-preview1-24530-04. In case it's an important detail, the project in question is a library project targeting 'netstandard1.6'.
The lack of the AccessToken property makes it difficult, if not impossible, to support modern directory-based auth scenarios for Azure SQL DB while also targeting .NET Standard (I have not attempted to use the connection string-based AAD options, but for various reasons those would not be applicable for my project). I have yet to find a workaround other than setting the target framework to 'net46', which I would like to avoid except as a last resort.
Related to dotnet/SqlClient#10
It's a bit strange that Azure is such a huge and important part of Microsoft, but .NET Standard and .NET Core aren't given the necessary resources to support it.
I don't mean to blame anyone here, it's just that I'd love to use .NET Core but still cannot do so more than 3 years after it was announced.
The PR referred to by @keeratsingh is https://github.com/dotnet/corefx/pull/30342
@nathandavidson @stijnherreman Closing this is issue since it is addressed by pr #30342.
@AfsanehR: great! So this will be released in .NET Core 2.2?
Security should be number 1. This should have been released already.
The PR was merged into master, which will ship in 3.0. I let @AfsanehR @David-Engel @keeratsingh to comment on option porting it to 2.2.
I think everyone waiting for this would like to see it in 2.2.
How this implementation will impact the pool connection key ? If there is two differents AccessToken with the same connection string, does it mean that they can share the same connection pool or not ?
A new connection pool is created for every access token.
+1 for getting this into .NET Core 2.2. By the time 2.2 comes out this issue will be 2 years old.
@AfsanehR @David-Engel @keeratsingh any decision on whether this update will be ported to 2.2?
@wienleung @Liero @paulirwin @stijnherreman We are currently in the process of porting this fix over to .NET Core 2.2, will updated here once the process is complete.
Reopening the issue to track port to 2.2 (PR dotnet/corefx#31039).
The AccessToken property is now added to .NET Core 2.2. 🎉
EDIT: While the PR was merged into the branch prior to 2.2 Preview1 release, it missed packaging changes and the package didn't ship at all, so it will be part of 2.2 Preview2 release (released on 2018/9/12).
Thanks @AfsanehR for addressing this popular issue. For those who will ask: we have not AFAIK announced a date for 2.2 yet. It will definitely be before 3.0 😀 Meantime, if anyone has a chance to try this out of the repo (either master or release/2.2) it would be great if you could indicate here to confirm you were successful.
2.2. is currently planned for Q4 2018: https://github.com/dotnet/core/blob/master/roadmap.md#upcoming-ship-dates
Can you give us an update on when we should be able to test this feature/start using it in development. Would that be 2.2.100-preview2?
Why can't this be distributed as a nuget package as opposed to with the full core sdk?
@jnevins-gcm shipping standalone packages leads to test matrix explosion + things don't work properly together when they should, etc. It caused lots of troubles for both the customers and the team and with .NET Core we started shipping platform as single NuGet package. You can check the feature in daily builds of release/2.2 build, or wait for next preview which will contain the fix (based on times and the schedule I am aware of, it should be Preview2).