Azure耐用功能处理异常以停止进一步执行
我有一个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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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.