gpt4 book ai didi

Azure 函数 - 使用 Active Directory 交互式身份验证连接到 Azure SQL 数据库

转载 作者:行者123 更新时间:2023-12-03 02:41:40 24 4
gpt4 key购买 nike

我在 Azure 函数中使用 SqlClient。目前,当我尝试创建一个传递连接字符串的新实例时,我收到以下消息

Keyword not supported: 'authentication'

我的连接字符串是

server=tcp:mydbserver.database.windows.net;database=mydb;UID=AnyString;Authentication=Active Directory Interactive

我的 Azure 函数已启用“身份”设置。

我作为 AppService 运行的其他 .NET 应用程序可以很好地连接到同一数据库,但它们使用 EntityFramework

我尝试删除 Authentication=Active Directory Interactive 并将以下行添加到连接

 connection.AccessToken = new Microsoft.Azure.Services.AppAuthentication.AzureServiceTokenProvider().GetAccessTokenAsync("https://database.windows.net/").Result;

但我只是收到不同的错误消息,例如用户“登录失败”或用户“NT AUTHORITY\ANONYMOUS LOGON”登录失败

谢谢!

最佳答案

确保使用 Microsoft.Data.SqlClient 而不是 System.Data.SqlClient 命名空间

关于Azure 函数 - 使用 Active Directory 交互式身份验证连接到 Azure SQL 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60936161/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com