Instead of using System.Data.SqlClient try downloading and using Microsoft.Data.SqlClient NuGet package. Maybe this article helps you solve the issue.
Authentication issue using Azure Managed Identity, SQL and C#
Hello First go at trying to use Azure Managed identity (MI) from a C# console app to connect to a Azure SQL Server but I'm getting an error regarding the Authentication key in the constructed connection string. The error is...
Invalid value for key 'authentication'.
My code will run on an app server for which I have enabled system assign MI in the Azure portal
Setup MI in Azure for the app server. In this case an IaaS running Windows.
Created the user in my DB like this
CREATE USER [MyServer] FROM EXTERNAL PROVIDER
EXEC sp_addrolemember N'db_owner', N'MyServer'
The C# code uses Dapper and System.Data.SqlClient
I read of few articles about how to construct the connection string in C# and I think I have it right, howerver it does seem odd that I have the Authentication key specified twice. Any ideas anyone?
Thanks
Azure SQL Database
Developer technologies | C#
1 answer
Sort by: Most helpful
-
Alberto Morillo 35,406 Reputation points MVP Volunteer Moderator2024-02-02T22:34:04.67+00:00