Termigez
Termigez

Reputation: 71

Azure Durable Functions handling exceptions to stop further execution

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.

Upvotes: 0

Views: 2269

Answers (1)

Delliganesh Sevanesan
Delliganesh Sevanesan

Reputation: 4776

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.

Upvotes: 0

Related Questions