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.
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+
- Open Options > Debugging > General
Then deselect “Just my code”
- 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. - Enable Verbose logging for Azure Functions host
First of all, enable verbose logging for the Azure Functions host – see how on this page
- 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?
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.
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:
- M365 Copilot claiming “You have turned off web search in the work mode”? Easy fix! - November 19, 2024
- “Performing cleanup” – Excel is stuck with an old, conflicted file and will never recover. - November 12, 2024
- How to add multiple app URIs for your Entra app registration? - November 5, 2024