Challenge: Applying Error Handling

Test yourself by applying error handling in Azure Functions.


Using the playground below, ensure that the function is robust enough to handle errors per the below requirements.


In the playground at the bottom of the page, we have a function with the timer trigger that runs every minute. Make some changes to it to apply some error handling. Perform the following tasks:

  • Add exception handling and error logging.

  • Add a retry policy.

Add exception handling and an error log

Firstly, make sure that the function only runs successfully during odd minutes. If the minute value of the current time is even, it should throw the InvalidOperationException. Catch this exception type and log both its message and its stack trace. Use the following template for the error log:

Get hands-on with 1200+ tech skills courses.