简体   繁体   English

在Azure Web App中针对AAD使用Active Directory密码时,“不支持关键字:身份验证”

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

I'm have an Azure Web App where I've set the connection string to point to an Azure SQL DB. 我有一个Azure Web App,其中已将连接字符串设置为指向Azure SQL DB。 I'd prefer to use an Azure Active Directory username/password for authentication so I used the following connection string: 我希望使用Azure Active Directory用户名/密码进行身份验证,因此我使用了以下连接字符串:

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 (ie remove the Authentication="Active Directory Password" and change User ID and Password to an appropriate SQL username and password), everything works as expected. 如果我使用SQL身份验证(即删除Authentication="Active Directory Password" ,并将User IDPassword更改为适当的SQL用户名和密码),那么一切都会按预期进行。

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? 是否可以将Active Directory Password与Azure Web App连接字符串一起使用,以便使用AAD用户名/密码连接到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();

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. 请注意Authentication关键字后面的文本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 带有证书的Python AAD(Azure Active Directory)身份验证 - Python AAD (Azure Active Directory) Authentication with certificate Azure Active Directory(AAD)即席身份验证 - Azure Active Directory (AAD) adhoc authentication 如何使用不记名令牌授权一个 Azure Active Directory 应用程序访问不同的 AAD 应用程序服务 Web API? - How do I authorize one Azure Active Directory app to access a different AAD App Service Web API using a Bearer token? Azure Web App从AAD身份验证注销 - Azure Web App logout from AAD Authentication Visual Studio 2017 WebTest使用Azure Active Directory(AAD)对Azure Web App进行身份验证 - Visual Studio 2017 WebTest authenticate Azure Web App with Azure Active Directory (AAD) Azure活动目录(AAD)身份验证,重定向URL不起作用 - Azure active directory (AAD) authentication, redirect URL not working Asp.net Identity使用密码和Azure Active Directory身份验证 - Asp.net Identity using password and Azure Active Directory authentication 使用 AAD 身份验证将 Blazor 应用程序部署到 Azure - Deploying Blazor app to Azure using AAD Authentication Azure 使用 Visual Studio 调试时不支持 Application Insights AAD 身份验证 - Azure Application Insights AAD authentication not supported when debbuging with Visual Studio 使用Azure AAD进行身份验证 - Authentication using Azure AAD
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM