“Keyword not supported: authentication” when using Active Directory Password against AAD in Azure Web App

我是研究僧i 提交于 2020-01-06 05:18:25

问题


I'm have an Azure Web App where I've set the connection string to point to an Azure SQL DB. I'd prefer to use an Azure Active Directory username/password for authentication so I used the following connection string:

Server=tcp:mydb.database.windows.net,1433;Initial Catalog=mytable;Persist Security Info=False;User ID={your_username};Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication="Active Directory Password";

This causes my app to fail with the error:

Keyword not supported: 'authentication'

If I use the SQL Authentication (i.e. remove the Authentication="Active Directory Password" and change User ID and Password to an appropriate SQL username and password), everything works as expected.

Is it possible to use Active Directory Password with an Azure Web App connection string in order to use an AAD username/password to connect to an Azure SQL Db?


回答1:


Please change the connection string as shown below:

string ConnectionString =
@"Data Source=n9lxnyuzhv.database.windows.net; Authentication=Active Directory Password; Initial Catalog=testdb;  UID=bob@contoso.onmicrosoft.com; PWD=MyPassWord!";
SqlConnection conn = new SqlConnection(ConnectionString);
conn.Open();

Another option:

string ConnectionString =
@"Data Source=n9lxnyuzhv.database.windows.net; Authentication=Active Directory Integrated; Initial Catalog=testdb;";
SqlConnection conn = new SqlConnection(ConnectionString);
conn.Open();

Please note the text following the Authentication keyword.



来源:https://stackoverflow.com/questions/54518643/keyword-not-supported-authentication-when-using-active-directory-password-aga

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!