Why are my Application Insights logs not being ingested from Azure Function App?

Niko Salminen 0 Reputation points
2024-08-23T06:30:09.7333333+00:00

I recently updated my C# based Azure Functions App to use the Application Insights SDK instead of just passing the APPINSIGHTS_INSTRUMENTATIONKEY. The logs work perfectly when I run the app on my development machine using func start but when I deploy it to Azure Functions nothing ends up in the logs. When I run union traces, exceptions, requests, dependencies, customMetrics I only see log messages sent from my laptop.

However, I'm able to see the log messages sent from Azure Functions in Live Metrics. After about an hour of waiting, I also see these trace messages:

AI: Diagnostic message: backoff logic disabled, transmission will be resolved.
AI: Diagnostic message: backoff logic was enabled. Backoff internal exceeded 40.6 min. Last status code received from the backend was 999.

The Function App is in a VNET but doesn't have any firewall enabled. The Network Security Group allows outbound access to anywhere. The services are all deployed in the Sweden Central location. The ingestion endpoint (https://swedencentral-0.in.applicationinsights.azure.com/v2.1/track) resolves and responds to tcpping on port 443.

My test application writes a log row per each log level from Trace to Critical. None of the rows appear in the Log Analytics workspace but everything from Warning upwards shows up in the Live Metrics as well as the Log Stream.

I tried to troubleshoot the network connectivity by opening up a Kudu PowerShell on the Function App but the Invoke-WebRequest doesn't work for any address I've tried. I tried with different TLS versions but they all give the same error:

PS C:\home> [Net.ServicePointManager]::SecurityProtocol
[Net.ServicePointManager]::SecurityProtocol
Tls12
PS C:\home> Invoke-WebRequest 'https://google.com'
Invoke-WebRequest 'https://google.com'
Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.
At line:1 char:1
+ Invoke-WebRequest 'https://google.com'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

What else could I try? I've already deleted and redeployed all the related resources.

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,254 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,975 questions
{count} votes

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.