首页 > 解决方案 > 新创建的 Azure 应用服务无法连接到现有的 Azure SQL 数据库

问题描述

我创建了一个新的 Azure 应用服务来测试登台。我将现有的应用程序部署到它,但它似乎无法访问现有的数据库。我总是得到这个例外:

Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - No such host is known.)
 ---> System.ComponentModel.Win32Exception (11001): No such host is known.
   at Microsoft.Data.ProviderBase.DbConnectionPool.CheckPoolBlockingPeriod(Exception e)
   at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at Microsoft.Data.ProviderBase.DbConnectionPool.WaitForPendingOpen()
--- End of stack trace from previous location where exception was thrown ---

但是连接字符串在设置中是正确的并且正确加载。我想可能是,我必须打开数据库上的防火墙才能使用新服务。但在数据库服务器上,该设置已被激活以授予所有服务访问权限。

在此处输入图像描述

所有服务都在同一个资源组中。而且我看不出应用服务设置有什么不同。我必须在某处明确启用某些东西吗?

编辑:我复制了现有的应用程序服务并部署到该服务。在这里我可以访问我复制的服务的数据库服务器,但不能访问第二个。所以我想我必须在某个地方调整一个设置才能启用它。

标签: azure

解决方案


最后,我编写了支持,并与他们一起创建了一个新的数据库服务器并复制了数据库。这样它就起作用了。


推荐阅读