Azure耐用功能处理异常以停止进一步执行

发布于 2025-02-12 19:54:44 字数 558 浏览 0 评论 0原文

我有一个Azure耐用函数(用C#编写),其中活动部分我经常连接到Azure SQL数据库以运行存储过程或从表中选择记录以进一步传递它们。

现在,我没有在代码中实现任何错误处理。当存储过程未完成错误原因时,我不想将此信息返回给用户。

我用来在耐用功能中执行活动部分中存储过程的功能看起来与:

var str = Environment.GetEnvironmentVariable("sqldb_connection");
using (SQLConnection conn = new SQLConnection(str))
{
conn.Open();
SQLCommand cmd = new SQLCommand("Stored_procedure", conn);
cmd.CommandType = CommandType.StoredProcedure;
var reader = cmd.ExecureReader();
conn.Close();
}

您能为我提供添加异常的方法,因此,如果此存储过程失败,我的其余活动都会停止?当存储此类信息(执行失败)以及如何检索这些信息时,我也非常感谢。

I have an Azure Durable Function (written in C#) where in Activity part I often connect to Azure SQL Database to run stored procedures or select records from table to pass them further on.

Right now I don't have any error handling implemented in my code. When stored procedure does not finish execution cause of error I do not return this information to the user however I would like to.

My functions that I use to execute stored procedures in activity part in my durable functions look similar to:

var str = Environment.GetEnvironmentVariable("sqldb_connection");
using (SQLConnection conn = new SQLConnection(str))
{
conn.Open();
SQLCommand cmd = new SQLCommand("Stored_procedure", conn);
cmd.CommandType = CommandType.StoredProcedure;
var reader = cmd.ExecureReader();
conn.Close();
}

Could you please provide me with ways to add exceptions, so if this stored procedure failes, the rest of my activity stops? I would also really appreciate when such information are stored (failed execution) and how to retrieve them.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如歌彻婉言 2025-02-19 19:54:44

AS junnas 说,如果一个活动函数会引发任何例外,它可以由编排者处理,它也称为> > FunctionFailDexceptions

如果该编排者在该异常日志记录中无法处理(失败),则该实例将以失败的状态记录,这意味着乐队函数没有实现/实现该例外。

应用程序洞察力将为您提供有关Azure功能以及持久功能的更多数据,您可以使用软件包dursableTask.sqlserver 。

请参阅耐用任务SQL Server记录“ nofollow noreferrer”> Orchestrator Excection Handling Microsoft提供的官方文档。

As Junnas said, If an activity function throws any exceptions, it can deal by the Orchestrator which are also known as FunctionFailedExceptions.

If that Orchestrator cannot handle (fails) in that exception logging, then the instance will be logged with a failed status which means Orchestrator function doesn't have implementation/implemented to that exception.

Application Insights will give you more data about the Azure Functions as well as Durable Functions where you can trace end-to-end execution of the Orchestration where you also have logging capabilities of SQL Server using the package DurableTask.SqlServer.

Refer to the Durable Task SQL Server Logging and Orchestrator exception handling official docs provided by Microsoft.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文