System.ArgumentException: Invalid value for key 'authentication' in connection string
Hello,
I am encountering the following exception when my application tries to connect with SQL Server database:
Unhandled exception. System.ArgumentException: Invalid value for key 'authentication'.
at Microsoft.Data.Common.DbConnectionStringBuilderUtil.ConvertToAuthenticationType(String keyword, Object value)
at Microsoft.Data.SqlClient.SqlConnectionStringBuilder.ConvertToAuthenticationType(String keyword, Object value)
at Microsoft.Data.SqlClient.SqlConnectionStringBuilder.set_Item(String keyword, Object value)
at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value)
at Microsoft.Data.SqlClient.SqlConnectionStringBuilder..ctor(String connectionString)
What I’ve Tried:
I’ve reviewed the connection string and noticed that the authentication key seems to be the source of the issue. Here is the connection string I am using:
"DefaultConnection": "Server=tcp:cxc-54rv1e-db.database.windows.net,1733;Initial Catalog=WatchTowerPPteDev;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;Authentication=Active Directory Default;",
I am getting error on the below line with the following exception:-
I’ve double-checked that the SQL Server supports the type of authentication I’m using, but I’m unsure whether the problem is with how the connection string is formatted or a mismatch in authentication methods.
Environment Details:
- .NET Version: 8.0.8
- SQL Server Version: SQL Server 2019
- Operating System: Windows Server 2019
- CoreCLR Version: 8.0.824.36612
Question:
What could be causing the System.ArgumentException: Invalid value for key 'authentication' error in my connection string, and how can I resolve it? Specifically, I’m unclear if the issue lies in the format of the authentication key or if there's something else.