Add actionable error message for missing Azure package when Entra ID auth methods are used#4046
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves the error message when users attempt to use Active Directory (Entra ID) authentication methods without having the required Microsoft.Data.SqlClient.Extensions.Azure NuGet package installed. Previously, the error simply said "Cannot find an authentication provider for '{method}'", which was not actionable. Now it explicitly tells users to install the Azure extensions package.
Changes:
- Changed
SQL.CannotFindAuthProviderto acceptSqlAuthenticationMethodenum instead ofstring, and return a more helpful error message for Active Directory auth methods that includes the package name and NuGet URL. - Added a new resource string
SQL_CannotFindActiveDirectoryAuthProviderwith actionable guidance. - Added unit tests covering both Active Directory and non-Active Directory authentication methods.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlUtil.cs |
Changed CannotFindAuthProvider parameter from string to SqlAuthenticationMethod and added switch to return AD-specific error message |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Connection/SqlConnectionInternal.cs |
Updated call site to pass enum directly instead of .ToString() |
src/Microsoft.Data.SqlClient/src/Resources/Strings.resx |
Added new SQL_CannotFindActiveDirectoryAuthProvider resource string |
src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs |
Auto-generated property for the new resource string |
src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/SqlUtilTests.cs |
New unit tests verifying error messages for both AD and non-AD auth methods |
Files not reviewed (1)
- src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Language not supported
You can also share your feedback on Copilot code review. Take the survey.
benrr101
left a comment
There was a problem hiding this comment.
Going forward, make sure that if you are reworking a PR to do the reworking in the same PR. If you close and resubmit a PR, all the comment history is wiped out, and it bypasses the requirement for a blocking review to be resolved before merging.
Description
Fixes #3962.
Issues
#3962
Testing
Added unit test
Guidelines
Please review the contribution guidelines before submitting a pull request: