Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure Worker可以';t连接到SQL;同一服务中的其他角色可以_Azure_Entity Framework 5_Azure Sql Database - Fatal编程技术网

Azure Worker可以';t连接到SQL;同一服务中的其他角色可以

Azure Worker可以';t连接到SQL;同一服务中的其他角色可以,azure,entity-framework-5,azure-sql-database,Azure,Entity Framework 5,Azure Sql Database,我正在从Azure云服务连接到SQL Azure数据库。四分之三的工作者角色可以与DB进行连接和交互,而不会出现任何问题。第四个,由于未知原因,在我第一次与DbSet交互时抛出此异常: System.Data.ProviderIncompatibleException: An error occurred while getting provider information from the database. This can be caused by Entity Framework usi

我正在从Azure云服务连接到SQL Azure数据库。四分之三的工作者角色可以与DB进行连接和交互,而不会出现任何问题。第四个,由于未知原因,在我第一次与DbSet交互时抛出此异常:

System.Data.ProviderIncompatibleException: An error occurred while getting
provider information from the database. This can be caused by Entity Framework
using an incorrect connection string. Check the inner exceptions for details and
ensure that the connection string is correct.
--->    System.Data.ProviderIncompatibleException: The provider did not return a 
ProviderManifestToken string.
---> System.Data.SqlClient.SqlException: 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: Named Pipes
Provider, error: 40 - Could not open a connection to SQL Server)
---> System.ComponentModel.Win32Exception: The system cannot find the file
specified
所有四个角色都使用相同的连接字符串(来自服务配置),使用来自同一程序集的Entity Framework 5 DbContext

以下是连接字符串:

Server=tcp:aaa.database.windows.net,1433;Database=AppName;User ID=appusername@aaa;Password=999;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;
在dev结构上运行时,我没有收到错误。我已尝试重新想象部署情况。SSMS连接良好


在第四个工人身上还有什么不同之处会导致这样的错误?

过去我见过像你这样奇怪的行为。一个VM连接到sql azure,另一个无法连接。问题是Azure分配的VM的IP。在Sql Azure上,您已启用“允许的服务-->WINDOWS Azure服务-->是”。但是有些ip地址(我想是太新了)并没有被SQLAzure识别为“Azure服务”。解决方案:等待IP更新(天?)或在sql azure上为您的IP添加一个明确的防火墙规则,该规则不起作用。

但我不确定是否与您的问题相同。

所以我最初的诊断有点不正确。它并不像我想的那样从服务配置中获取连接字符串。它来自app.config

问题原来与TFS的连续部署有关。默认的构建/部署脚本没有充分注意内容文件,例如app.config!这是给所有四名工人相同的副本,而不是将他们的包裹分开。这是一个相当大的问题


我没有找到解决方案或解决办法;改变WWF XAMLs不是我知道该怎么做的事情。我只是加倍确保我只从服务配置中获取设置(在本例中,在运行时将其设置为NLog)。

如果它与TFS构建问题相关,那么在构建多个工作角色时,配置文件被覆盖时,我也会遇到同样的问题,在我的例子中,它是使用传递给msbuild.exe的/m:1参数解决的。更多详细信息可在此处找到:

这是无法连接的云服务中的第四个角色,还是该服务中角色的第四个实例?第四个角色。每个角色目前只运行一个实例。请尝试运行5个角色,查看是否只有第4个角色失败,或者同时运行4和5个角色。