Setting up Raygun with Azure WebJobs

Callum GavinProvider Updates4 Comments

Azure WebJobs provide a nice, low-impact way to run scheduled or continuous programs against Azure Websites, with easy setup and a good monitoring dashboard. When you need small, occassional housekeeping tasks run against your sites, or constant jobs, using a WebJob removes the hassle of manually copying over console apps to the server and setting them up as scheduled tasks.

Packaging a new or pre-existing console app as a WebJob is pretty painless thanks to good VS2013 integration. It’s just as easy to integrate Raygun with a WebJob, giving you deep visibility into how all your processes are erroring out at runtime, without having to manually dig through logfiles.

Deploying a console WebJob

Firstly, to get a console app up on Azure you can follow the guide here. Once you’ve added the NuGet package, right-clicked on the project and gone through the wizard, a JSON settings file will be created – from here you can deploy to an Azure Website. The History tab in the dashboard will list when the console app was run (according to the schedule you set), which means it’s ready for Raygun integration to show what exceptions occurred.

Integrating Raygun into a WebJob

You’ll need to first grab the Raygun4NET package from NuGet:

To set up Raygun4NET in a console app, you can hook up to the unhandled exception delegate:

That’s all there is to it! Completing this contrived example, that ThrowAnException method might look something like this:

Deploying this project by right-clicking and selecting ‘Publish as Azure WebJob’ will make it available to be run when next scheduled. The resulting exception above will be caught and sent automatically, and the resulting Raygun report looks like this:

The full stacktrace is available, ready to be debugged. If you’ve chosen to get email notifications, and if it’s the first time this exception has been thrown, you’ll get an email informing you of this. If it’s occurred before you’ll get stats on how many times it’s been reported, and the trend.

Grab your Raygun trial

Got Raygun and Azure accounts already? Dive in and hook up your WebJobs to Raygun now! We’ve also got NuGet packages for MVC and WebAPI projects so you can easily set up your Azure projects with Raygun. And if you need a Raygun account, as always there’s the free trial available here.

Next level software intelligence across your entire stack.

4 Comments on “Setting up Raygun with Azure WebJobs”

  1. Brandon Schenz

    I made the simple sample work as expected, however when I move up to make use of QueueTriigers and an exception is thrown it does not seem to go to the unhandled exception delegate….

    Any ideas of what I’m doing wrong in this model?

    1. Austin

      I’m running into the same problem. Is there a work-around or should I just wrap my code that uses a QueueTrigger in a try catch and manually send the exception to Raygun, then re-throw the exception?

Leave a Reply

Your email address will not be published. Required fields are marked *