.net application hosted on azure stopped working & exception occurred [Win32Exception (0x80004005): Access is denied] [SqlException (0x80131904):

huangapple go评论69阅读模式
英文:

.net application hosted on azure stopped working & exception occurred [Win32Exception (0x80004005): Access is denied] [SqlException (0x80131904):

问题

我的.NET网站托管在Azure上,一切正常,但突然停止工作,并出现以下错误。 请确认以下内容:

  1. 问题是否来自Azure方面
  2. 还是来自SQL方面
  3. 如何解决这个问题。
堆栈跟踪:
[Win32Exception(0x80004005):访问被拒绝]
[SqlException(0x80131904):建立与SQL Server的连接时发生与网络相关或特定于实例的错误。 未找到服务器或服务器无法访问。 请验证实例名称是否正确,并且SQL Server已配置为允许远程连接。 (提供程序:命名管道提供程序,错误:40 - 无法打开与SQL Server的连接)]
HomePage.btn_Search_Click(Object sender,EventArgs e)+1526
<Page_Load>d__2.MoveNext()+745
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+32
System.Web.Util.SynchronizationHelper.SafeWrapCallback(Action action)+114
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+32
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)+62
System.Web.Util.WithinCancellableCallbackTaskAwaiter.GetResult()+33
System.Web.UI.<LoadRecursiveAsync>d__246.MoveNext()+492
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+32
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)+62
System.Web.Util.WithinCancellableCallbackTaskAwaiter.GetResult()+33
System.Web.UI.<ProcessRequestMainAsync>d__523.MoveNext()+6951
英文:

My .NET site is hosted on azure and working fine but suddenly it get stopper and below error occurred.
Please confirm below:
1.Is the issue from azure side
2. or from SQL side
3. how I can resolve this.

Stack Trace:
[Win32Exception (0x80004005): Access is denied]
[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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
   HomePage.btn_Search_Click(Object sender, EventArgs e) +1526
   <Page_Load>d__2.MoveNext() +745
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32
   System.Web.Util.SynchronizationHelper.SafeWrapCallback(Action action) +114
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62
   System.Web.Util.WithinCancellableCallbackTaskAwaiter.GetResult() +33
   System.Web.UI.<LoadRecursiveAsync>d__246.MoveNext() +492
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62
   System.Web.Util.WithinCancellableCallbackTaskAwaiter.GetResult() +33
   System.Web.UI.<ProcessRequestMainAsync>d__523.MoveNext() +6951

答案1

得分: 1

以下是翻译好的部分:

  1. Is it related to DB itself? - Depending on where the DB is hosted and the type of DB (Microsoft SQL, mySql etc.), verify its status and try connecting to it using any of the tools available. For example, in the case of Microsoft Azure/SQL Server, you might use sqlcmd tool or SQL Server Management Studio can be used for this purpose.

    1. 与数据库本身有关吗?- 取决于数据库托管的位置和数据库类型(如Microsoft SQL、mySql等),请验证其状态并尝试使用任何可用工具连接到它。例如,在Microsoft Azure/SQL Server的情况下,您可以使用sqlcmd工具SQL Server Management Studio进行连接。
  2. Is the webApps trying to connect to the correct SQL DB? - Once you have verified that the DB is up and running, the next step would be to ensure that your web application is connecting to the correct DB. The connection string used to specify this db in the application will have to be checked to ensure that there are no errors in the server/db/userId/Password etc.
    2. Web应用程序是否尝试连接到正确的SQL数据库?- 一旦您确认数据库正在运行,下一步是确保您的Web应用程序正在连接到正确的数据库。必须检查用于指定应用程序中的数据库的连接字符串,以确保服务器/数据库/用户ID/密码等没有错误。

  3. Is it related to connectivity/permission - If everything is verified to be fine based on the points above, the next step would be to ensure that the web app is able to reach out to the DB (there are no network/permission issues). Looking at the logs on SQL Server itself could provide some insights. For example, for Microsoft SQL Server (hosted on Windows Server), in EventViewer\Application logs, you would see event 18456 if there is a login issue - which would mean that the connectivity is fine, but the authentication method used is failing. In this case, you will have to assign correct permission to the identity/userid which is being used by the webApp for connecting to the SQL Server.
    3. 是否与连接/权限有关 - 如果根据上述要点一切都验证正常,那么下一步就是确保Web应用程序能够访问数据库(没有网络/权限问题)。查看SQL Server本身的日志可以提供一些见解。例如,对于托管在Windows Server上的Microsoft SQL Server,在EventViewer/Application日志中,如果存在登录问题,您将看到事件18456 - 这意味着连接正常,但使用的身份验证方法失败。在这种情况下,您需要为Web应用程序用于连接到SQL Server的身份/用户ID分配正确的权限。

如果问题与网络本身有关,即请求甚至无法到达数据库,取决于SQL Server托管的位置,您可以执行以下操作:

  1. 验证服务器是否配置为允许远程连接。对于Azure SQL数据库,如果您不断收到错误,可以参考此链接
  2. 如果此错误偶尔发生,可能是暂时性问题,此链接应该对您有所帮助。

查看SQL Server错误日志以获取有关错误的更多信息。

英文:

The errors reported in the question are not related to Azure Web App itself. It could be or could not be related to the DB itself. The error is mainly for connectivity failure i.e., the application code is not able to establish connection with DB.

The first step here would be isolate the issue:

1. Is it related to DB itself? - Depending on where the DB is hosted and the type of DB (Microsoft SQL, mySql etc.), verify its status and try connecting to it using any of the tools available. For example, in the case of Microsoft Azure/SQL Server, you might use sqlcmd tool or SQL Server Management Studio can be used for this purpose.

2. Is the webApps trying to connect to the correct SQL DB? - Once you have verified that the DB is up and running, the next step would be to ensure that you web application is connecting to correct DB. The connection string used to specify this db in application will have to be checked to ensure that there are no errors in server/db/userId/Password etc.

3. Is it related to connectivity/permission - If everything is verified to be fine based on the points above, the next step would be to ensure that the web app is able to reach out to db (there are no network/permission issues). Looking at the logs on SQL Server itself could provide some insights. For example, for Microsoft SQL Server (hosted on Windows Server), in EventViewer\Application logs, you would see event 18456 if there is a login issue - which would mean that the connectivity is fine, but the authentication method used is failing. In this case, you will have to assign correct permission to the identity/userid which is being used by webApp for connecting to the SQL Server.

In case the issue is related to network itself, i.e., the requests are not even reaching out to DB, depending on where the SQL Server is hosted you can perform the following:

  1. Verify that the server is configured to allow remote connections. For Azure SQL DB you can refer to this link, if you are always getting an error.
  2. If this error occasionally, it could be a transient issue and this link should help you.

Check the SQL Server error log for more information about the error.

huangapple
  • 本文由 发表于 2023年2月9日 03:24:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/75390792.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定