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 January 23rd, 2020.

Reading Time: 3 minutes.

I dont’ 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 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’s 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.

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

  1. Open Options > Debugging > General
  2. Unselect “Just my code”
  3. See the screenshot below!

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 below:

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! It helped me continued the investigation I’ve described in the article below:

mm

Leave a Reply

avatar
5000
  Subscribe  
Notify of