从Azure App Service中的API连接到本地SQL Server

问题描述:

我正在尝试从我已部署到Azure App Service的API连接到本地SQL Server.我已建立一个Azure混合连接以在本地SQL和Azure之间进行连接.我创建了一个连接字符串,其中包括用户名和密码,就像我在本地服务器中创建的本地登录名一样.这允许我连接.

I am trying to connect to an on-premises SQL Server from my API which i have deployed to Azure App Service. I have established a Azure Hybrid Connection to connect between on-premises SQL and Azure. I created a connection string which included username and password as that of a local login i created in the On-Premises server. This is allowing me to connect.

连接字符串:

Data Source=;Initial Catalog=;User=;Password=;MultipleActiveResultSets=True

但是我想使用Windows身份验证连接到服务器.我的系统帐户可以在服务器*问,但是在将连接字符串用作-

However i want to connect to the server using windows authentication. My System account has access on the server, but when using connection string as -

Data Source=;Initial Catalog=;Integrated Security=SSPI;User=;Password=;

Data Source=;Initial Catalog=;Integrated Security=SSPI;

错误提示为

"登录失败.登录来自不受信任的域,不能为 与Windows身份验证配合使用."

"Login failed. The login is from an untrusted domain and cannot be used with Windows authentication."

在从Azure App Service形成到本地SQL Server的连接字符串时,请建议如何使用Windows身份验证模式.

Please suggest how to use windows mode of authentication while forming connection string to the on-premises SQL Server from Azure App Service.

Azure混合连接似乎不支持Active Directory,因此Windows身份验证将不起作用.请参阅官方MS文档中有关sql auth的注释.

Azure Hybrid Connection does not appear to support Active Directory and hence Windows Authentication will not work. See note about sql auth being required in Official MS documentation.

https://docs.microsoft .com/zh-CN/azure/biztalk-services/integration-hybrid-connection-overview

另外,请查看以下SO问题,其中一个答案详细说明了此设置面临的常见问题:

Also, look at the following SO question where one of the answers details common issues faced this setup:

C#Web应用程序未通过Azure混合连接连接到本地SQL Server

您不太可能解决此问题,尤其是当您将应用程序托管为网络应用程序时.

You are unlikely to get around this, especially if you are hosting your app as a web app.