2

我正在尝试将 ASP.net Web 应用程序发布到 Azure 云。我必须使用混合连接来与我的一个 SQL Server 通信。我相信我已经正确设置了它;但是,我的实体框架连接字符串似乎不起作用。

这是我的混合连接字符串在 Azure 门户中相应 Azure 应用服务下的样子:

Name: serverdev
Status: Connected
Endpoint: ipaddress:49188
Namespace: serverCon

这是混合连接管理器在目标 SQL Server 上的样子:

Name: serverDev
Azure Status: Connected
Service Type: Relay
Service Name: serverCon
Endpoint: ipaddress:49188
Service Bus Endpoint: serverCon.servicebus.windows.net
AzureIP Address: azureIpAdress
AzurePorts: 80,443

因此,看起来混合连接配置正确。

这是我的 Entity Framework 连接字符串在我的web.config中的样子:

<add name="EDUONNWEntities" connectionString="metadata=res://*/DBModels.WarehouseModel.csdl|res://*/DBModels.WarehouseModel.ssdl|res://*/DBModels.WarehouseModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;connectionString;initial catalog=EDUONNW;persist security info=True;user id=username;password=password;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />
Note: connectionString = to the connection string of my sql server when testing my web app outside of the cloud (on my local dev machine, everything works fine of course).

这是我收到的例外情况:

System.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.)

在我看来,我的 Azure App Service 不知道使用基于我的 Entity Framework 连接字符串的混合连接。我觉得我错过了一些简单的东西。任何帮助表示赞赏!

谢谢你,Snawwz

4

1 回答 1

0

我确实意识到这是一篇旧帖子,但我会做出回应,以防其他人为此苦苦挣扎。我有一个类似的问题,要解决它,我必须在发布选项中设置我的实体的连接字符串:

连接字符串:
连接字符串

于 2020-01-20T21:59:45.090 回答