Can not connect to Azure SQL Server using Active directory integrated authentication in AppService

谁都会走 提交于 2019-12-11 07:34:56

问题


We have web application deploy on Azure App Service. Our database is also on Azure which is configured to use AAD authentication (We have assigned AAD Admin).

We are using below connection string in web app to connect to this server and database using below connections string.

Data Source=xxxxxxx.database.windows.net;Initial Catalog=xxxxxxx;Persist Security Info=False;Authentication=Active Directory Integrated

Please note: This connection string is working fine when using thru local system. But getting below error when we use this conn string in Azure App Service:

Failed to authenticate the user NT Authority\Anonymous Logon in Active Directory (Authentication=ActiveDirectoryIntegrated). Error code 0x4BC; state 10 The format of the specified domain name is invalid


回答1:


According to your description, I found you used the Active Directory integrated authentication.

To use integrated Windows authentication, your domain’s Active Directory must be federated with Azure Active Directory. Your client application (or a service) connecting to the database must be running on a domain-joined machine under a user’s domain credentials

If you published the web app to Azure, Azure's web app server will not be in your domain’s Active Directory. So the SQL server will not pass the auth.

I suggest you could try to use Active Directory password authentication instead of the Active Directory integrated authentication.

Replace the connection string as below use azure AD user name and password. It will work well.

Server=tcp:brandotest.database.windows.net,1433;Initial Catalog=bradnotestsql;Persist Security Info=False;User ID={your_username};Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication="Active Directory Password";



回答2:


Maybe all you need to use is token (certificate) authentication as explained on below resource:

https://github.com/Microsoft/sql-server-samples/tree/master/samples/features/security/azure-active-directory-auth/token

Try to register your application with Azure Active Directory as explained on that resource.

Hope this helps.



来源:https://stackoverflow.com/questions/46681021/can-not-connect-to-azure-sql-server-using-active-directory-integrated-authentica

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!