Missing Application Insights and Monitor in Python Function App

184 views Asked by At

I have a workspace and configure it with my Application insights. I added instrument key and connection string of app insight in configuration of the function. App insight was working when the function is public. But now monitor part and app insight dashboards, failures are not working. What is missing?

enter image description here enter image description here enter image description here enter image description here

Configuration between log analytics workspace and Python func app is ready. But I could not get any data from app insights and monitor part. I have no quota for getting data, too.

Log analytics workspace: "dailyQuotaGb": -1, this value indicates that there is no daily quota set for data ingestion in the workspace. Therefore, it essentially means there is no limit on the amount of data that can be ingested into the workspace on a daily basis.

This is one message from functionapplogs related my function app's appinsights:

 ApplicationInsightsLoggerOptions { 'SamplingSettings': { 'EvaluationInterval': '00:00:15', 'InitialSamplingPercentage': 100.0, 'MaxSamplingPercentage': 100.0, 'MaxTelemetryItemsPerSecond': 20.0, 'MinSamplingPercentage': 0.1, 'MovingAverageRatio': 0.25, 'SamplingPercentageDecreaseTimeout': '00:02:00', 'SamplingPercentageIncreaseTimeout': '00:15:00' }, 'SamplingExcludedTypes': 'Request', 'SamplingIncludedTypes': null, 'SnapshotConfiguration': null, 'EnablePerformanceCountersCollection': true, 'HttpAutoCollectionOptions': { 'EnableHttpTriggerExtendedInfoCollection': true, 'EnableW3CDistributedTracing': true, 'EnableResponseHeaderInjection': true }, 'LiveMetricsInitializationDelay': '00:00:15', 'EnableLiveMetrics': true, 'EnableLiveMetricsFilters': false, 'EnableDependencyTracking': true, 'DependencyTrackingOptions': null }

and also I added this solution also from Microsoft:

Since your function app is inside a VNET, it is possible that you have the VNET_ROUTE_ALL app setting set to 1 forcing all traffic via the VNET.

If the VNET doesn't have an outbound rule for the AzureMonitor Service Tag, application insight requests won't get through

1

There are 1 answers

8
Suresh Chikkam On

We can get the monitor alerts and app insight dashboards, failures by configuring app insights to our function you can follow below steps.

  • Here I created a normal function app/default app with runtime python in vs code.

Then I have configured azure app insights with my function in local.setting.json file.

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "python",
    "APPINSIGHTS_INSTRUMENTATIONKEY": "your_instrumentation_key_here"
  }
}
  • To check if it's functioning or not, I changed my code in this instance by adding a fake exception to receive a trace from my app insights.
from applicationinsights import TelemetryClient
import time

# Simulate custom event
client.track_event("FakeEvent", properties={"key": "value"})

# Simulate custom metric
client.track_metric("FakeMetric", 42)

# Simulate exception
try:
    # Code that might raise an exception
    raise ValueError("Simulated exception")
except Exception as e:
    client.track_exception()

# Flush telemetry data
client.flush()

You can see the exception generated while running the function app and those exceptions are traced as a failure in my app insight.

enter image description here

Dashboard:

enter image description here