Azure Observability on Tap - End-to-End Azure Monitoring - Part 5

Integrating Application Insights with Azure Monitor. It’s not just about “the cloud is slow” it’s about *why*. App Insights brings runtime context into your observability setup.

Why App Insights Matters

Most platform metrics & logs only get you down to the host, container, or connection level.

Application Insights takes you deeper:

  • In code performance
  • Custom events
  • End-to-end distributed traces
  • Real user monitoring (RUM)

This is the layer where Dev meets Ops true full-stack observability.

Connecting App Insights into the Pipeline

Two options

  1. Autoinstrumentation via App Service, .NET, Java
  2. Manual SDK init for custom apps (Node.js, Python, etc.)

Once wired in, App Insights connects into Azure Monitor:

  • Sends logs to Log Analytics
  • Shows in Application Map
  • Correlates to trace IDs and transaction flows

Portal Walkthrough: App Insights

  1. Go to Application Insights (create if needed)
  2. In your App Service:
    • Monitoring → Application Insights
    • Link to existing or create new
  3. View the Application Map
  4. Check:
    • Server Response Time
    • Dependencies
    • Failures
    • Exceptions (with stack trace!)
    • Request Drilldown

Querying App Insights via KQL

1
2
3
requests
| where success == false
| project timestamp, name, resultCode, duration, cloud_RoleName
1
2
3
dependencies
| where type == "http" and duration > 1000
| project timestamp, target, name, duration

Use Case: Performance Bottleneck in Web App

  1. Alert fires: increase in 5xx HTTP
  2. Jump into App Insights → Trace affected request
  3. View context:
    • Which dependency failed?
    • Which method threw?
    • Which DB call took longest?

You’ll also see correlation IDs that link back to activity in Log Analytics.

Bicep: Connect App Insights to App Service

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
param appServiceName string
param appInsightsName string

resource ai 'Microsoft.Insights/components@2020-02-02' = {
  name: appInsightsName
  location: resourceGroup().location
  kind: 'web'
  properties: {
    Application_Type: 'web'
  }
}

resource appService 'Microsoft.Web/sites@2023-01-01' existing = {
  name: appServiceName
}

resource insightsLink 'Microsoft.Web/sites/extensions@2023-01-01' = {
  name: '${appService.name}/applicationInsights'
  dependsOn: [ai]
  properties: {
    InstrumentationKey: ai.properties.InstrumentationKey
  }
}

Gotchas

  • Sampling enabled by default – can miss some traces (adjust if needed)
  • Cold starts in Functions skew performance data
  • Not everything emits by default—opt into custom events where needed

Best Practices

  • Use App Map to visualise distributed transactions
  • Always include custom dimensions in telemetry to enrich logs by env, tenant, user ID
  • Export logs to Log Analytics Workspace for unified querying
  • Test lifecycle: App Insights can detect startup times and deployment regressions
  • Use end-to-end Transaction Search it’s underrated gold
🍺
Brewed Insight: You don’t need to instrument everything but you should instrument what matters. Application Insights is the difference between “The app is slow” and “That SQL query in Line 43 is the problem.”

Learn More