User Logging of FunctionInvocationException or RpcException

Travis Troyer 0 Reputation points
2023-12-11T20:17:47.1+00:00

Our organization is using Azure Functions, as well as a number of other Azure products, and we generally use Splunk to capture log output from all of the components within our overall solution. Unfortunately, we'll occasionally run into a FunctionInvocationException or an RpcException caught by the Azure Function host. These make it to Application Insights, but there appears to be no way from our code to capture and log these exceptions, so we have to monitor both Splunk and Application Insights to ensure that everything in functioning properly. With everything else making it to Splunk, I'd really love to get these exceptions routed there too.

Is there an Azure Functions feature or some setup I'm missing? Or should I turn this into a feature request? Maybe something like ASP.NET Core's IExceptionHandler would by handy.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,911 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MayankBargali-MSFT 70,936 Reputation points Moderator
    2023-12-18T12:40:33.6733333+00:00

    @Travis Troyer Thanks for reaching out.

    It seems like you are looking for a way to capture and log exceptions that are caught by the Azure Function host in Splunk. While Azure Functions integrates with Application Insights to collect telemetry data, it does not provide a built-in way to route exceptions to Splunk. However, there are a few options you can consider to achieve this.

    One option is to use Azure Monitor Logs to consolidate logs from different resources, including Azure Functions, in the same workspace. You can then stream your logs and events to a Logs Analytics workspace and connect Microsoft Sentinel to this workspace for enterprise-level threat detection and response automation. You can learn more about this in the Monitoring Azure Functions with Azure Monitor Logs article.

    Another option is to use Azure Functions' built-in logging feature to log exceptions to a file or to a third-party logging service such as Serilog or NLog. You can then configure Splunk to monitor the log files or the logging service to capture the exceptions. You can learn more about this in the Analyze Azure Functions telemetry in Application Insights article.

    If you decide to use a third-party logging service, you can use the logging framework of your choice, such as ASP.NET Core's ILogger or Serilog's ILogger, to capture and log exceptions. You can then configure the logging service to send the logs to Splunk.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.