Automated-Fact-Checking-Resources icon indicating copy to clipboard operation
Automated-Fact-Checking-Resources copied to clipboard

Nothing logged if SqlAuthenticationProviders is configured for system.data.sqlclient

Open Daniel-Svensson opened this issue 3 years ago • 1 comments

Please clearly describe what the SQL Sink is doing incorrectly:

Nothing is logged. Selflog report a type initialization exception for Microsoft.data settings provider or similar and a message that a system.data type cannot be cast to the corresponding Microsoft.data type.

solution manually referring to Microsoft.data.sqlclient version 4 (or any release >= 2.1) solves the issue.

2.1 release notes: https://github.com/dotnet/SqlClient/blob/main/release-notes/2.1/2.1.0.md#sqlclientauthenticationproviders-configuration-section

Please clearly describe the expected behavior: Logs are sent to database

List the names and versions of all Serilog packages used in the project:

  • Serilog: latest as of 20220103
  • Serilog.Sinks.MSSqlServer: 5.5-5.6
  • (configuration, etc.)

the connection string might need to contain any specific authentication mode such as "Active Directory Integrated", but I don't know for certain if that is required or not.

Target framework and operating system:

[ ] .NET Core 2.0 [X ] .NET Framework 4.8 (net 4.7.2 as well) [ ] .NET Framework 4.6.x [ ] .NET Framework 4.5.x OS:

Provide a simple reproduction of your Serilog configuration file, if any:

Provide a simple reproduction of your application code:

Copy code from https://devblogs.microsoft.com/dotnet/announcing-the-net-framework-4-7-2/#sql-azure-ad-universal-and-multi-factor-authentication-support or setup "SqlAuthenticationProviders" in app/web.config for system.data.sqlclient

Call test method and then setup the mssqlsink and log an event

Daniel-Svensson avatar Jan 04 '22 13:01 Daniel-Svensson

Workaround: manually reference a later version of Microsoft.data.sqlclient such as 4.0 in the application solves the problem ( or downgrade the sink to 5.4)

Daniel-Svensson avatar Jan 04 '22 13:01 Daniel-Svensson

We have now upgraded Microsoft.Data.SqlClient to version 5.0.1 and removed the sink native Azure Managed Identity support. This should fix this issue.

ckadluba avatar Dec 28 '22 00:12 ckadluba