John Hoerr John Hoerr - 5 months ago 26
C# Question

What’s the best way to signal a failure in an Azure Function?

When writing an Azure Function in compiled C#/F#, what's the cleanest way to signal to the Function runtime that the function failed?

I know that throwing an exception will result in a failure, but I'd prefer to handle those internally. I've also noticed that when when the function writes to

the execution is still considered successful.

Is throwing an exception the only way to signal a failure, or is there a better practice?

Answer Source

Yes, throwing an exception is how you signal a failure. Even if you log errors inside of your function, the function host doesn't take that into consideration when determining success/failure.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download