Enabling Exceptions in Azure Functions

2.6k Views Asked by At

I'm attempting to debug my Azure Function App, all I get is "An error has occurred" which is making fixing my issues extremely difficult. Any idea how to enable full exceptions to be returned by the application? Anything to make debugging possible as I'm massively blocked by this right now.

Many thanks.

Nick.

Edit: In the table storage log for the function I see the following error,

...obs.Script.Description.FunctionInvokerBase.<Invoke>d__29.MoveNext()--- End of stack trace from previous location where exception was thrown ---   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)   at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`1.<InvokeAsync>d__8.MoveNext()--- End of stack trace from previous location where exception was thrown ---   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.<InvokeAsync>d__22.MoveNext()--- End of stack trace from previous location where exception was thrown ---   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.<ExecuteWithWatchersAsync>d__21.MoveNext()--- End of stack trace from previous location where exception was thrown ---   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.<ExecuteWithLoggingAsync>d__19.MoveNext()--- End of stack trace from previous location where exception was thrown ---   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.<ExecuteWithLoggingAsync>d__13.MoveNext()   --- End of inner exception stack trace ---

I see this error even if I manually throw an exception on the first line. Where is the real exception?

enter image description here Looking at these logs really makes me question Microsoft's decisions at times, how is this useful to anyone? Or am I missing something crucial here?

1

There are 1 best solutions below

0
On BEST ANSWER

Okay so this is my solution, this may vary depending on what's wrong for you as the error is so generic. Firstly what I done was disable authentication for my function to try to get the in-browser compiler to work again as this has been broken ever since I done this, it didn't help, it resulted in 404 errors for all of my functions. So I enabled it again, this caused the compiler to start working! It showed that I had a reference mismatch for Azure Storage, somehow my dll was referencing 7.x but was expecting 6.x in the function app, which is odd as I don't recall ever changing it. Anyway, I created a project.json file with the following in,

{
  "frameworks": {
    "net46":{
      "dependencies": {
        "WindowsAzure.Storage": "7.2.1"
      }
    }
   }
}

After uploading this to the folder of each function, it works again. I will now explicitly set all of my external dependencies via a project.json file to hopefully prevent this from happening again.

It's worth noting that although this doesn't make the full exception get returned in-browser, it did enable me to see compiler errors, which is what was causing the issue and preventing me from handling any exceptions in the function app.

-

One last note and to show how buggy Azure Function Apps are, even though Authentication is "enabled" according to the app settings, it's not working, this is why the in-browser compiler is now working. I'm working on getting it working again, but won't be replying to this thread anymore. Just be wary.