Azure Functions host be like ...

How to extract more information out of your Azure Functions host failing silently?

This post was most recently updated on July 31st, 2022.

2 min read.

I don’t know about you, but it’s happened to me a few times: fire up your Azure functions project, hit F5 to start debugging project builds without errors, Azure Functions host starts… And shuts down right away.

This article has a few quick and simple tips on how to extract a bit more information from the Azure Functions host (func.exe), when it’s just silently failing. This means by default you won’t get any information about what’s going wrong. However, a couple of steps should get you a long way here!

Problem

This situation is frustrating to debug (nothing in Event Log, breakpoints won’t stick and the console app just disappears), but being able to extract a bit more information out of the situation might help you figure out what’s going on!

Something like below.

Azure Functions host is up, but clearly not functional
Azure Functions host is up, but clearly not functional…

This window would show up for a few seconds and then disappear.

Solutions

There are a couple of steps you can do to extract a bit more info out of your Azure Functions host. First of all, turn on breaking on all exceptions (i.e. by disabling breaking only for your code) with the following instructions.

Time needed: 10 minutes

How to enable break on all exceptions on Visual Studio 2017+

  1. Open Options > Debugging > General

    Then deselect “Just my code”



  2. Tools > Options > Debugging > General

    Alternatively, to avoid some edge cases with exceptions in libraries crashing your code before your breakpoints are hit, enable this setting as well:

    “Break when exceptions cross AppDomain or managed/native boundaries” in Tools > Options > Debugging > General

    This should enable you to grab any exceptions thrown in the code. However, the functions host might again go down in flames and you might STILL be none the wiser.

    Two more steps to do, if you still don’t hit a breakpoint OR get some useful output to work with.

  3. Enable Verbose logging for Azure Functions host

    First of all, enable verbose logging for the Azure Functions host – see how on this page

  4. Last resort: Run, don’t debug

    After that, the last step – be sure to start the Azure Functions host without debugging. I know – this is super basic. Still, it’s a useful step to remember.

    By default, the keybinding is Ctrl+F5 but it might be different for you. Starting without debugging should help you get SOME logging out of the execution.

    How to "start without debugging" in Visual Studio?
    How to “start without debugging” in Visual Studio?


With any luck, since debugging won’t crash anymore, you’ll see an actual error this time. The additional information might be helpful when trying to figure out what went wrong in your code.

For instance, I got this information, in the screenshot below.

Azure Functions Core Tools (2.4.432) Function Runtime Version: 2.0.12332.0 - The system cannot find the file specified. Press any key to continue . . .
Azure Functions Core Tools (2.4.432) Function Runtime Version: 2.0.12332.0 – The system cannot find the file specified. Press any key to continue . . .

Looks obtuse still, right? Sure, but at least it helped me in googling!

This particular error – “The system cannot find the file specified” – helped me continue the investigation I’ve described in the article below:

mm
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments