In this year’s //oneweek Hackathon at Microsoft, I built a quick ASP.Net front end for our project. During the hackathon we need to be innovative AND fast! In our case we had several web jobs (background tasks) for grooming information and inserting new data in the database. We needed a FAST way to get alerts if any of those background tasks weren’t working correctly without adding additional infrastructure to the solution. Here are some options we considered:
- Write another Web Job (background task) that keeps a watch on the existing jobs and reports any problems via email on SendGrid
- Add App Insights custom events / exception handling and check the portal for alerts periodically
- Add good exception handling in the existing Web Jobs and send email directly for any issues
We settled on something completely different – we wanted to leverage App Insights rich reporting and email capabilities, didn’t want to add additional infrastructure at this time during the Hackathon and needed something done FAST. Here’s what we ended up doing:
- Create a new Controller (DataChecker) with a single action (check data) and an empty View
- In the controller action, we implemented any custom logic we wanted for checking the validity of the data (last execution time, last time records were changed, etc) and threw an exception if something wasn’t correct
- In the Azure Portal, in the App Insights blade, we implemented a URL Ping test pointed at the action we created above.
The good news is that we get emails quickly if there are any issues with our data PLUS we have a place (right inside our website) to add more unit tests or custom logic for verifying things in the database. You can use this strategy of having a simple ASP.Net Controller Action to do ‘stuff’ and then wire it to App Insights for a lot things.
Leave a comment below if you found this useful or want a more complete walkthrough!