【问题标题】:Using Active Directory Authentication for Azure SQL server in .Net Core App 1.1在 .Net Core App 1.1 中为 Azure SQL 服务器使用 Active Directory 身份验证
【发布时间】:2018-01-22 13:21:17
【问题描述】:

我想在 .Net Core App 1.1 中使用 Azure Active Directory 身份验证连接到我的 Azure SQL 服务器。

关于使用类似于以下连接字符串的连接字符串:

Data Source=n9lxnyuzhv.database.windows.net; Authentication=Active Directory Integrated; Initial Catalog=testdb;

我得到了这个例外:

System.ArgumentException: 'Keyword not supported: 'authentication'.'

我了解 AAD Auth 可用于 .Net Framework 4.6 及更高版本中的 SQL 服务器。是否可以通过 .Net Core Apps 中的 AAD 连接到服务器。如果有,怎么做?

感谢任何帮助。

【问题讨论】:

    标签: asp.net sql-server azure azure-active-directory asp.net-core-1.1


    【解决方案1】:

    目前,.Net Core 不支持 Microsoft SQL Server 的 Microsoft Active Directory 身份验证库。请参考这个feedback

    通过为 Azure SQL Server 设置 Active Directory Admin,您可以使用 SQL Server Management Studio 登录到 SQL Server。在您的应用程序或用户使用 Azure Active Directory 用户/应用程序连接到 Azure SQL 数据库或 Azure SQL 数据仓库的所有客户端计算机上,您必须安装以下软件:

    • .NET Framework 4.6 或更高版本

    • 适用于 SQL Server 的 Azure Active Directory 身份验证库 (ADALSQL.DLL) 支持多种语言(x86 和 amd64)

    这个blog 可能有帮助。

    【讨论】:

    • adalsql.dll 已经存在于我机器的系统文件夹中。我能够通过 .Net Framework 4.6 应用程序使用 Azure AD 连接到 SQL 服务器。但是 .Net Core 1.1 应用程序给了我上述异常。
    • @M_coder 根据official documentSQL Server 2016 Management Studio and SQL Server Data Tools for Visual Studio 2015 (version 14.0.60311.1April 2016 or later) support Azure Active Directory authentication. (Azure AD authentication is supported by the .NET Framework Data Provider for SqlServer; at least version .NET Framework 4.6).
    • @M_coder 好像Azure Active Directory Authentication for authentication with SQL Database不支持.Net Core Apps。
    • @M_coder 请参考这个answerNET Core on the other hand is a subset of .NET Framework 4.6 which is mainly optimized for multi-platform and cloud deployments。如果要对 SQL 使用 Azure AD 身份验证,则应使用 .NET framework 4.6。
    • 这是我最初担心的,它可能还不受 .Net Core 应用程序的支持。感谢您的及时回复。
    猜你喜欢
    • 2017-09-05
    • 2019-10-31
    • 1970-01-01
    • 2016-02-14
    • 2020-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-29
    相关资源
    最近更新 更多