“不支持关键字:认证";在Azure Web App中针对AAD使用Active Directory密码时 [英] "Keyword not supported: authentication" when using Active Directory Password against AAD in Azure Web App

查看:84
本文介绍了“不支持关键字:认证";在Azure Web App中针对AAD使用Active Directory密码时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Azure Web App,其中已将连接字符串设置为指向Azure SQL DB.我希望使用Azure Active Directory用户名/密码进行身份验证,因此我使用了以下连接字符串:

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'

如果我使用SQL身份验证(即删除Authentication="Active Directory Password"并将User IDPassword更改为适当的SQL用户名和密码),则一切正常.

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.

是否可以将Active Directory Password与Azure Web App连接字符串一起使用,以便使用AAD用户名/密码连接到Azure SQL Db?

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?

推荐答案

请如下所示更改连接字符串:

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();

另一个选择:

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

请注意Authentication关键字后面的文本.

Please note the text following the Authentication keyword.

这篇关于“不支持关键字:认证";在Azure Web App中针对AAD使用Active Directory密码时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆