9

我们最近在生产部署过程中将客户端迁移到 SQL Azure 平台。从所有外在迹象来看,它是成功的:与之相连的网络应用程序都在工作。

但是,当我们查看 Azure 监视器时,我们会看到许多失败的连接。我们还没有找到太多解释什么是连接失败的文档。我们的用户都没有报告问题。有谁知道这怎么可能?

在此处输入图像描述

使用本文中的示例查询(查看 SQL Azure 实例上的连接问题

SELECT      
            [Date From] = EL.[start_time],
            [Date To] = EL.[end_time],
            [Database Name] = EL.[database_name],
            [Event Type] = EL.[event_type],
            [Event Sub Type] = EL.[event_subtype_desc],
            [Description] = EL.[description],
            [Additional Data] = EL.additional_data
FROM sys.event_log EL
WHERE EL.event_type != 'connection_successful'
AND EL.event_subtype_desc != 'idle_connection_timeout'
ORDER BY [Date From] DESC

我们看到这样的结果:

2013-04-19 16:40:00.0000000 2013-04-19 16:45:00.0000000 [DATABASE]  connection_failed   blocked_by_firewall Client IP address is not allowed to access the server.  NULL
2013-04-19 16:40:00.0000000 2013-04-19 16:45:00.0000000             connection_failed   blocked_by_firewall Client IP address is not allowed to access the server.  NULL
2013-04-19 16:35:00.0000000 2013-04-19 16:40:00.0000000 [DATABASE]  connection_failed   blocked_by_firewall Client IP address is not allowed to access the server.  NULL
2013-04-19 16:35:00.0000000 2013-04-19 16:40:00.0000000             connection_failed   blocked_by_firewall Client IP address is not allowed to access the server.  NULL
2013-04-19 16:30:00.0000000 2013-04-19 16:35:00.0000000 [DATABASE]  connection_failed   blocked_by_firewall Client IP address is not allowed to access the server.  NULL
2013-04-19 16:30:00.0000000 2013-04-19 16:35:00.0000000             connection_failed   blocked_by_firewall Client IP address is not allowed to access the server.  NULL
2013-04-19 16:25:00.0000000 2013-04-19 16:30:00.0000000 [DATABASE]  connection_failed   blocked_by_firewall Client IP address is not allowed to access the server.  NULL
2013-04-19 16:25:00.0000000 2013-04-19 16:30:00.0000000             connection_failed   blocked_by_firewall Client IP address is not allowed to access the server.  NULL
2013-04-19 16:20:00.0000000 2013-04-19 16:25:00.0000000 [DATABASE]  connection_failed   blocked_by_firewall Client IP address is not allowed to access the server.  NULL
2013-04-19 16:20:00.0000000 2013-04-19 16:25:00.0000000             connection_failed   blocked_by_firewall Client IP address is not allowed to access the server.  NULL
2013-04-19 16:15:00.0000000 2013-04-19 16:20:00.0000000 [DATABASE]  connection_failed   blocked_by_firewall Client IP address is not allowed to access the server.  NULL

以及我们的连接字符串示例,根据要求:

  <add name="[MyContext]"
     providerName="System.Data.SqlClient"
     connectionString="
      Server=tcp:[machine].database.windows.net,1433;
          Database=[database];
          User ID=[user]@[machine];
          Password=[password];
          Trusted_Connection=False;
          Encrypt=True;
          Connection Timeout=30;"/>
4

2 回答 2

1

因此,自发布的第一天起,我们就再也没有看到失败的连接。我目前的想法是,Azure 端可能有一个后端进程无法与新实例一起正常运行,但此后要么停止,要么已修复,因为我们没有更改任何内容。我会让它再坐几天,如果我们没有发现更多问题,请将其归结为环境设置故障。

在此处输入图像描述

这是一周左右后的状态。不是一个频繁使用的站点,但没有任何连接错误的迹象。

在此处输入图像描述

于 2013-04-23T20:23:07.837 回答
1

我遇到了同样的问题,它让我感到困惑,直到我意识到我在我的家庭办公室机器上打开并连接了一个 SQL Server Management Studio 实例,并且我的 ISP 更改了我的 IP 地址!一旦我关闭 SSMS,失败的连接就会停止。感谢 OP 提供指向 SQL 查询的链接,这也很有用!

于 2019-10-24T05:28:17.447 回答