Azure网站有时无法连接到SQL Azure数据库

Can*_*ğlu 5 asp.net azure azure-sql-database

我一直在Azure测试一个网站大约一个月(免费试用),现在我已经订阅了现收现付版.当我参加免费试用时,我绝对没有连接问题.现在,我再次部署到一个新的网站,该网站使用与前一个相同的设置(缩放模式等)在按需付费订阅中创建.但是,现在当我导航到我的网站时,它有时无法连接到我的数据库:

Server Error in '/' Application.
A connection attempt failed because the connected party did not properly respond after
a period of time, or established connection failed because connected host has failed to
respond
Description: An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and where
it originated in the code.

Exception Details: System.ComponentModel.Win32Exception: A connection attempt failed 
because the connected party did not properly respond after a period of time, or
established connection failed because connected host has failed to respond

Source Error:

An unhandled exception was generated during the execution of the current web request.
Information regarding the origin and location of the exception can be identified using
the exception stack trace below.

Stack Trace:


[Win32Exception (0x80004005): A connection attempt failed because the connected party 
did not properly respond after a period of time, or established connection failed 
because connected host has failed to respond]

[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 - A connection attempt
failed because the connected party did not properly respond after a period of time, or
established connection failed because connected host has failed to respond.)
Run Code Online (Sandbox Code Playgroud)

我尝试刷新页面并连接.几分钟后,当我再次尝试时,我有时会再次遇到同样的错误,但有时候不会.我在免费试用模式下从未遇到过单一连接问题.为什么会发生这种情况?如何防止此问题?

CSh*_*cks 4

云环境中预计会出现暂时性错误。假设数据库调用失败,如果您在几毫秒后重试,那么相同的调用现在可以工作。为了避免这些错误,您需要实现重试逻辑。如果您使用实体框架 6,那么您很幸运,因为它已内置:http : //msdn.microsoft.com/en-US/data/dn456835 以下是有关如何实现此功能的快速视频:http://www.Entity Framework 6。 azurerocks.com/0_oaw-merMw

您还可以使用企业库瞬态故障处理应用程序块:http://msdn.microsoft.com/en-us/library/hh680934 (v=pandp.50).aspx

  • 我会看看它。知道为什么这种情况整整一个月都没有发生,但在我转向付费订阅后才开始发生吗? (2认同)