【发布时间】:2021-11-20 21:33:53
【问题描述】:
我正在尝试利用 AAD 身份访问 Azure SQL 服务器,而不是 SQL 服务器用户。 我正在关注这篇文章https://docs.microsoft.com/en-us/azure/azure-sql/database/authentication-aad-configure。 我需要根据 Microsoft 文档做的是在数据库中创建包含的用户。所以我从 Azure Function 应用程序执行此操作。
CREATE USER [existing group in AAD] FROM EXTERNAL PROVIDER
ALTER ROLE db_datareader ADD MEMBER [existing group in AAD]
函数应用能够登录 SQL Server,因为它的服务主体设置为 SQL Server 的 Azure Active Directory 管理员。
我遇到了异常:
Principal 'existing group in AAD' could not be resolved. Error message: 'AADSTS700016: Application with
identifier '168d4e19-6718-4e50-8f96-c280e821ad6c' was not found in the directory 'my directory'. This can
happen if the application has not been installed by the administrator of the tenant or consented to by any
user in the tenant. You may have sent your authentication request to the wrong tenant.
所以我将系统分配托管标识分配给 SQL 服务器。然后我得到了:
Server identity does not have Azure Active Directory Readers permission. Please follow the steps here : https://docs.microsoft.com/en-us/azure/azure-sql/database/authentication-aad-service-principal
我根据需要为该身份分配了 Directory Readers 权限,并且它开始工作。
我的问题是我需要使用用户分配托管身份,所以我做了同样的事情,但遇到了第一个异常,例如没有为 SQL 服务器分配身份。
任何想法为什么系统分配的身份有效但用户分配的身份无效?
【问题讨论】:
-
你用的是什么类型的sql server? azure sql,管理实例,其他?
-
我正在使用 Azure SQL
标签: azure azure-active-directory azure-sql-database azure-managed-identity