Application Insights for Node error and no console logs

Zundalek Zbynek 25 Reputation points
2023-02-22T04:24:44.3333333+00:00

Hi,

Application Insights for Node in Azure portal shows error Configuration for Node is not available through the portal for this app because i) a different runtime stack was selected during creation or ii) we are unable to detect the runtime stack. Please refer to the document below. and I can't get console logs from Application Insights.

I've started from scratch and build sample node app https://learn.microsoft.com/en-us/azure/app-service/quickstart-nodejs?tabs=windows&pivots=development-environment-vscode and deployed it to Azure WebApp (Windows operation system, Node version 18). I can see the console.logs in log stream, but when I setup the Application Insights I get the following error.

image

But according to the documentation this should be displayed:User's image

I've tried the troubleshooting described in: https://learn.microsoft.com/en-us/azure/azure-monitor/app/azure-web-apps-nodejs?tabs=windows#troubleshooting

Configuration:

ApplicationInsightsAgent_EXTENSION_VERSION: ~2
XDT_MicrosoftApplicationInsights_NodeJS: 1
WEBSITE_NODE_DEFAULT_VERSION: ~18
SCM_DO_BUILD_DURING_DEPLOYMENT: true

And the status should be running but is not.

image

I've tried to access logs from Web App -> Application Insights-> Logs and I can get requests, but no traces or AppServiceConsoleLogs.

Auto-instrumentation should be supported according to https://learn.microsoft.com/en-us/azure/azure-monitor/app/codeless-overview#supported-environments-languages-and-resource-providers

Thank you.

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,517 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,492 questions
{count} votes

Accepted answer
  1. ajkuma 28,116 Reputation points Microsoft Employee
    2023-03-06T12:08:08.9033333+00:00

    @Zundalek Zbynek , Following-up on this -

    Application Insights Node.js Agent cannot be configured in portal, but it can be configured using JSON file, checkout this article for more info: https://github.com/microsoft/ApplicationInsights-node.js#configuration

    JSON need to be part of app and use APPLICATIONINSIGHTS_CONFIGURATION_FILE to specify the path so Agent can find it. Please try this and let us know, we will be more than happy to assist you further.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Zundalek Zbynek 25 Reputation points
    2023-03-06T05:54:52.6033333+00:00

    Thank you Ajkuma for your help you've saved my day!

    I'm still not able to make it run on Windows but I'm able to make it run on Linux at least!

    I've set up Application Insights for Node through Azure FE:

    User's image

    But get no console logs so I've created a json file applicationinsights.json in home directory:

    
    {
      "samplingPercentage": 100,
      "enableAutoCollectExternalLoggers": true,
      "enableAutoCollectConsole": true,
      "enableAutoCollectExceptions": true,
      "enableInternalWarningLogging": true,
      "enableInternalDebugLogging": true,
      "enableAutoCollectHeartbeat": true,
      "enableSendLiveMetrics": true
    }
    

    And set variable APPLICATIONINSIGHTS_CONFIGURATION_FILE to /home/applicationinsights.json as you suggested. It finally works without any problems now.

    PS: It would be nice if other people don't have to spend hours to set up basic things like this because the documentation is not helpful at all.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.