且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Azure App Service无法访问SQL Server-用户'NT AUTHORITY \ ANONYMOUS LOGON'登录失败

更新时间:2022-04-16 09:08:28

最终在这里找到了答案>>

Eventually found the answer here >> https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/tutorial-windows-vm-access-sql#create-a-contained-user-in-the-database-that-represents-the-vms-system-assigned-identity

App Service确实已设置为服务器的所有者,但没有在数据库上设置用户,因此我的问题通过登录进入得以解决通过SSMS并运行数据库:

The App Service was indeed set as an owner of the server, but hadn't had a user provisioned on the database, so my problem was resolved by logging into the database via SSMS and running:

CREATE USER [My App Service Name] FROM EXTERNAL PROVIDER

然后:

ALTER ROLE db_owner ADD MEMBER [My App Service Name]

但是,我在服务器的访问控制(IAM)页面上删除了App Service的所有权角色,并且仍然能够成功连接,不确定为什么会这样,但这可能只是我缺乏SQL用户知识部分.实际上,这很适合我,因为目前我的App Service在数据库本身(而不是整个服务器)上分配了具有db_owner角色的预配置SQL用户.

However, I removed the ownership role of the App Service on the server's Access Control (IAM) page, and am still able to connect successfully, not sure why that is but this is probably just a lack of SQL user knowledge on my part. It actually suits me as at the moment my App Service has a provisioned SQL user with db_owner role assigned on the database itself, but not on the overall server.