Supporting Azure Functions and WebJobs
Ensuring that elmah.io works great with any web and logging framework for .NET, is a key priority for us. Serverless development using Azure Functions and WebJobs (as well as AWS Lambdas) have gained a lot of traction during the last years. Logging errors from Functions and WebJobs have been supported using our API client for a while, but today we are ready to introduce native support. Let me introduce you to Elmah.Io.Functions.
With the Elmah.Io.Functions
NuGet package, logging errors from Azure Functions and WebJobs requires only a single line of code. In the following example, I'm logging all errors happening in a timed function. Start by installing the Elmah.Io.Functions
package:
Install-Package Elmah.Io.Functions -Pre
And now for the code:
[ElmahIoExceptionFilter("API_KEY", "LOG_ID")]
public static class Function1
{
[FunctionName("Function1")]
public static void Run([TimerTrigger("0 */1 * * * *")]TimerInfo myTimer, TraceWriter log)
{
// Your business logic goes here
}
}
Look ma, no try catch! That's right. The ElmahIoExceptionFilter
attribute automatically logs all unhandled exceptions in your business logic.
As always, let us know if you need help integrating elmah.io into your Function/WebJobs project. We're here to help.
elmah.io: Error logging and Uptime Monitoring for your web apps
This blog post is brought to you by elmah.io. elmah.io is error logging, uptime monitoring, deployment tracking, and service heartbeats for your .NET and JavaScript applications. Stop relying on your users to notify you when something is wrong or dig through hundreds of megabytes of log files spread across servers. With elmah.io, we store all of your log messages, notify you through popular channels like email, Slack, and Microsoft Teams, and help you fix errors fast.
See how we can help you monitor your website for crashes Monitor your website