Skip to content

Add additional logging to state whether the function app has content (to debug '0 functions loaded') when starting the Functions Host #9515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Francisco-Gamino opened this issue Sep 7, 2023 · 2 comments

Comments

@Francisco-Gamino
Copy link
Contributor

Francisco-Gamino commented Sep 7, 2023

Currently, we do not have a simple way to debug the '0 functions loaded' message. This log entry typically indicates that the Functions Host was unable to find and load any functions within the function app project.

If the function app has content, this means that there is a problem with the package (content); otherwise, the issue is that there is no content, and this message is expected.

Current logging:

Source Summary
Host.Startup Loading functions metadata
Microsoft.Azure.WebJobs.Script.HostFunctionMetadataProvider Reading functions metadata
Microsoft.Azure.WebJobs.Script.HostFunctionMetadataProvider 0 functions found
Host.Startup 0 functions loaded

Additionally, we should create documentation that describes how to debug the '0 functions loaded' message, which is very specific to the type of runtime (Dotnet, Dotnet-Isolated, NodeJs, Java, PowerShell, and Python). This new documentation should contain debugging instructions for both the V1 and V2 programming models if applicable.

If the function app has content, we should do one of the following:

  1. Create a diagnostic event that indicates there is a problem with the function app package, and the Functions Host is unable to find and load any functions.

private static readonly Action<ILogger, int, Exception> _functionMetadataManagerFunctionsLoaded =
LoggerMessage.Define<int>(LogLevel.Information,
new EventId(315, nameof(FunctionMetadataManagerFunctionsLoaded)),
"{count} functions loaded");

  1. Update the existing log to include a fwlink that directs users to documentation on how to resolve this issue, for example,
    https://aka.ms/function-app-invalid-content.

One more thing to consider: If the app has no content, perhaps we should append additional guidance to the '0 functions loaded' message, providing information on how to deploy content to the function app.

/cc @FinVamp1 @sidkri @paulyuk @vrdmr @mattchenderson @fabiocav

@Francisco-Gamino
Copy link
Contributor Author

Documentation work items for '0 functions loaded':
DotNet: #9524
NodeJs: Azure/azure-functions-nodejs-worker#716
Java: Azure/azure-functions-java-worker#725
Python: Azure/azure-functions-python-worker#1315
PowerShell: Azure/azure-functions-powershell-worker#999

@ejizba
Copy link
Contributor

ejizba commented Sep 15, 2023

In my opinion the fix should focus on discoverability of host startup errors, rather than trying to document how to fix each individual error. There are clear errors in the host logs, but the user just isn't seeing them for a few reasons:

  1. A lot of "clear" errors we see in the backend just aren't visible to the user in their app insights at all, which is seriously hampering the worker team's ability to improve supportability: #9360
  2. Most users only look at deployment logs, not app insight logs, but from the tooling perspective the deployment technically succeeded. I feel like if we're going to make improvements, tooling is where we can make the most impact (Azure Dev Ops, core tools, etc.). For example:
    • Most tooling has their own logic to query the list of functions after a deployment. If they find zero, we could add an aka.ms link to their "No functions found" logs, which is similar but different from the host's "0 functions loaded" log. Again, I think the doc should just point users to app insights or "diagnose and solve problems" rather than how to fix each individual error, though.
    • In an ideal world, we could have tooling do some sort of post-deployment validation, query for host startup logs directly, and display any errors to the user. VS Code did something like this for web apps a couple years ago, although I know it wasn't easy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants