title | description | ms.service | ms.date | ms.devlang | ms.custom | ms.topic | zone_pivot_groups |
---|---|---|---|---|---|---|---|
Troubleshoot Node.js apps in Azure Functions | Learn how to troubleshoot common errors when you deploy or run a Node.js app in Azure Functions. | azure-functions | 09/20/2023 | javascript | devx-track-js | troubleshooting-general | functions-nodejs-model |
[!INCLUDE functions-nodejs-model-pivot-description]
This article provides a guide for troubleshooting common scenarios in Node.js function apps.
The Diagnose and solve problems tab in the Azure portal is a useful resource to monitor and diagnose possible issues related to your application. It also supplies potential solutions to your problems based on the diagnosis. For more information, see Azure Function app diagnostics.
Another useful resource is the Logs tab in the Azure portal for your Application Insights instance so that you can run custom KQL queries. The following example query shows how to view errors and warnings for your app in the past day:
letmyAppName = "<your app name>"; letstartTime = ago(1d); letendTime = now(); union traces,requests,exceptions | where cloud_RoleName =~ myAppName | where timestamp between (startTime .. endTime) | where severityLevel > 2
If those resources didn't solve your problem, the following sections provide advice for specific application issues:
If you see any of the following errors in your logs:
No HTTP triggers found.
No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
Try the following fixes:
::: zone pivot="nodejs-model-v4"
- When running locally, make sure you're using Azure Functions Core Tools v4.0.5382 or higher.
- When running in Azure:
Make sure you're using Azure Functions Runtime Version 4.25 or higher.
Make sure you're using Node.js v18 or higher.
Set the app setting
FUNCTIONS_NODE_BLOCK_ON_ENTRY_POINT_ERROR
totrue
. This setting is recommended for all model v4 apps and ensures that all entry point errors are visible in your application insights logs. For more information, see App settings reference for Azure Functions.Check your function app logs for entry point errors. The following example query shows how to view entry point errors for your app in the past day:
letmyAppName = "<your app name>"; letstartTime = ago(1d); letendTime = now(); union traces,requests,exceptions | where cloud_RoleName =~ myAppName | where timestamp between (startTime .. endTime) | where severityLevel > 2 | where message has"entry point"
::: zone-end ::: zone pivot="nodejs-model-v3"
- Make sure your app has the required folder structure with a host.json at the root and a folder for each function containing a function.json file. ::: zone-end
::: zone pivot="nodejs-model-v4"
If you get the following error in your function app logs:
System.Private.CoreLib: Exception while executing function: Functions.httpTrigger1. System.Private.CoreLib: Result: Failure Exception: undici_1.Request is not a constructor
Make sure you're using Node.js version 18.x or higher.
If you get the following error in your function app logs:
WARNING: Failed to detect the Azure Functions runtime. Switching "@azure/functions" package to test mode - not all features are supported.
Check your package.json
file for a reference to applicationinsights
and make sure the version is ^2.7.1
or higher. After updating the version, run npm install
::: zone-end
You can get more help from Microsoft in one of the following ways:
- Search the known issues in the Azure Functions Node.js repository. If you don't see your issue mentioned, create a new issue and let us know what has happened.
- If you're not able to diagnose your problem using this guide, Microsoft support engineers are available to help diagnose issues with your application. Microsoft offers various support plans. Create a support ticket in the Support + troubleshooting section of your function app page in the Azure portal.