Azure的网站有时无法连接到SQL Azure数据库 [英] Azure website sometimes can't connect to SQL Azure database

查看:260
本文介绍了Azure的网站有时无法连接到SQL Azure数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在测试天青网站约一个月(免费试用),而现在我已经订阅了付费为你去。当我的免费试用,我绝对没有连接问题。现在我再次部署到具有相同设置的薪酬为你去订阅创建了一个新的网站(缩放模式等)为previous之一。但是,现在当我浏览到我的网站,有时无法连接到我的数据库:

I've been testing a website in Azure for about a month (Free trial), and now I've subscribed to pay-as-you-go. When I was on the free trial, I had absolutely no connectivity issues. Now I've deployed again to a fresh website created on the pay-as-you-go subscription with the same settings (scaling mode etc.) as the previous one. However, now when I navigate to my site, it sometimes fails to connect to my database:

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

我尝试刷新页面,并将其连接。几分钟后,当我再试试,我有时会再次得到了同样的错误,但有时并非如此。我从来没有在免费试用模式有一个单一的连接问题。为什么它的发生和哪能prevent这个问题?

I try to refresh the page and it connects. After a few minutes, when I try again, I sometimes get the same error again, but sometimes not. I never had a single connectivity issue in the free trial mode. Why does it happend and how can I prevent this problem?

推荐答案

预计在云环境中的瞬态错误。比方说,一个数据库调用失败,如果您稍后重试几毫秒的时间,同样的通话将现在的工作。为了从这些错误中保护你,你需要实现重试逻辑。如果您使用实体框架6,你很幸运,因为它的出炉:的http:// msdn.microsoft.com/en-US/data/dn456835
下面是关于如何实现一个快速的视频: http://www.azurerocks.com/0_oaw-merMw

Transient errors are expected in a cloud environment. Let's say that a database call fails, if you retry a few milliseconds later, that same call would now work. To shield you from these errors, you need to implement a retry logic. If you use Entity Framework 6, you're in luck since it's baked in: http://msdn.microsoft.com/en-US/data/dn456835 Here's a quick video on how to implement this: http://www.azurerocks.com/0_oaw-merMw

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

You can also use the Enterprise Library Transient Fault Handling Application Block: http://msdn.microsoft.com/en-us/library/hh680934(v=pandp.50).aspx

这篇关于Azure的网站有时无法连接到SQL Azure数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆