AppInsights instrumentation
Identify the app stack and Azure hosting model, create or reuse Application Insights infrastructure, and add the minimum code or platform configuration needed for useful telemetry, preferring auto-instrument paths when they fit.
When to invoke
- "Enable Application Insights for this webapp."
- "Instrument my ASP.NET Core app with App Insights."
- "Add telemetry to a Node.js or Python app hosted in Azure."
- "Create the App Insights resource and wire the connection string."
Prerequisites and context
- The workspace app should be an ASP.NET Core app, a Node.js app, or a Python web app.
- The hosting target should be known: Azure App Service as code, Azure App Service as container, Azure Container Apps, local development, or another Azure host.
- Azure resource creation requires an authenticated Azure CLI or existing Bicep deployment workflow.
- Prefer the same resource group as the hosted app unless the user's resource organization requires a different one.
Procedure
- Inspect source files to infer the programming language, application framework, and hosting tuple.
- Ask for or infer the Azure hosting model before choosing instrumentation. In non-interactive execution, state the assumption and choose the safest documented path.
- Prefer Azure App Service auto-instrumentation for C# ASP.NET Core hosted in Azure App Service; use
references/AUTO.md.
- If auto-instrumentation does not fit, create or update the Application Insights resource through existing Bicep or Azure CLI.
- Modify application code using the stack-specific guide:
references/ASPNETCORE.md, references/NODEJS.md, or references/PYTHON.md.
- Validate that configuration uses the Application Insights connection string or the platform-supported setting and that telemetry can be emitted without hardcoded secrets.
Instrumentation decision table
| App and hosting |
Preferred path |
Files to consult |
| ASP.NET Core on Azure App Service |
Auto-instrument first. |
references/AUTO.md |
| ASP.NET Core requiring code instrumentation |
Add SDK/configuration in app startup. |
references/ASPNETCORE.md |
| Node.js web app |
Add Node.js Application Insights initialization as early as possible in process startup. |
references/NODEJS.md |
| Python web app |
Add Python instrumentation appropriate to the framework and startup path. |
references/PYTHON.md |
| Existing Bicep infrastructure |
Add the App Insights resource to the template. |
examples/appinsights.bicep |
| No IaC available |
Use Azure CLI commands from the script as a model. |
scripts/appinsights.ps1 |
Infrastructure rules
- Add Application Insights to existing Bicep when the workspace already contains Bicep templates.
- Use Azure CLI from
scripts/appinsights.ps1 when no infrastructure-as-code path exists.
- Do not hardcode instrumentation keys, connection strings, subscription IDs, tenant IDs, or secrets in source code.
- Store runtime configuration in Azure app settings, environment variables, or the repository's existing secret mechanism.
- Instrument useful telemetry: request/dependency tracking, exceptions, logs/traces, and custom events only when they answer an operational question.
Progressive disclosure and bundled resources
references/AUTO.md: Azure App Service auto-instrumentation guidance.
references/ASPNETCORE.md: ASP.NET Core code changes.
references/NODEJS.md: Node.js JavaScript/TypeScript code changes.
references/PYTHON.md: Python web app code changes.
examples/appinsights.bicep: Bicep resource example.
scripts/appinsights.ps1: Azure CLI command model for creating the resource.
Output template
## Application Insights instrumentation result
**Status:** instrumented | recommendation only | blocked
**App stack:** `<language, framework, hosting>`
**Instrumentation path:** auto-instrumentation | ASP.NET Core SDK | Node.js SDK | Python SDK | infrastructure only
| Change | File/resource | Evidence |
| --- | --- | --- |
| `<resource created or code updated>` | `<path or Azure resource>` | `<setting, package, or snippet>` |
### Configuration
- Application Insights resource group: `<resource group or assumed target>`
- Connection setting location: `<app setting/env var/IaC output>`
### Validation
- Telemetry startup path checked: <yes/no>
- Secret hardcoding avoided: <yes/no>
Quality gate
1---2name: appinsights-instrumentation3description: Instrument Azure-hosted web apps with Azure Application Insights telemetry by choosing auto-instrumentation or code instrumentation for ASP.NET Core, Node.js, or Python. Use when the user wants to enable telemetry, observe app health, create an App Insights resource, or wire instrumentation into a webapp.4---56<!-- Generated from harness/github-copilot/skills/appinsights-instrumentation/SKILL.md by harness/claude-code/scripts/convert_from_copilot.py. Edit the source, not this file. -->78# AppInsights instrumentation910Identify the app stack and Azure hosting model, create or reuse Application Insights infrastructure, and add the minimum code or platform configuration needed for useful telemetry, preferring auto-instrument paths when they fit.1112## When to invoke1314- "Enable Application Insights for this webapp."15- "Instrument my ASP.NET Core app with App Insights."16- "Add telemetry to a Node.js or Python app hosted in Azure."17- "Create the App Insights resource and wire the connection string."1819## Prerequisites and context2021- The workspace app should be an ASP.NET Core app, a Node.js app, or a Python web app.22- The hosting target should be known: Azure App Service as code, Azure App Service as container, Azure Container Apps, local development, or another Azure host.23- Azure resource creation requires an authenticated Azure CLI or existing Bicep deployment workflow.24- Prefer the same resource group as the hosted app unless the user's resource organization requires a different one.2526## Procedure27281. Inspect source files to infer the programming language, application framework, and hosting tuple.292. Ask for or infer the Azure hosting model before choosing instrumentation. In non-interactive execution, state the assumption and choose the safest documented path.303. Prefer Azure App Service auto-instrumentation for C# ASP.NET Core hosted in Azure App Service; use `references/AUTO.md`.314. If auto-instrumentation does not fit, create or update the Application Insights resource through existing Bicep or Azure CLI.325. Modify application code using the stack-specific guide: `references/ASPNETCORE.md`, `references/NODEJS.md`, or `references/PYTHON.md`.336. Validate that configuration uses the Application Insights connection string or the platform-supported setting and that telemetry can be emitted without hardcoded secrets.3435## Instrumentation decision table3637| App and hosting | Preferred path | Files to consult |38| --- | --- | --- |39| ASP.NET Core on Azure App Service | Auto-instrument first. | `references/AUTO.md` |40| ASP.NET Core requiring code instrumentation | Add SDK/configuration in app startup. | `references/ASPNETCORE.md` |41| Node.js web app | Add Node.js Application Insights initialization as early as possible in process startup. | `references/NODEJS.md` |42| Python web app | Add Python instrumentation appropriate to the framework and startup path. | `references/PYTHON.md` |43| Existing Bicep infrastructure | Add the App Insights resource to the template. | `examples/appinsights.bicep` |44| No IaC available | Use Azure CLI commands from the script as a model. | `scripts/appinsights.ps1` |4546## Infrastructure rules4748- Add Application Insights to existing Bicep when the workspace already contains Bicep templates.49- Use Azure CLI from `scripts/appinsights.ps1` when no infrastructure-as-code path exists.50- Do not hardcode instrumentation keys, connection strings, subscription IDs, tenant IDs, or secrets in source code.51- Store runtime configuration in Azure app settings, environment variables, or the repository's existing secret mechanism.52- Instrument useful telemetry: request/dependency tracking, exceptions, logs/traces, and custom events only when they answer an operational question.5354## Progressive disclosure and bundled resources5556- `references/AUTO.md`: Azure App Service auto-instrumentation guidance.57- `references/ASPNETCORE.md`: ASP.NET Core code changes.58- `references/NODEJS.md`: Node.js JavaScript/TypeScript code changes.59- `references/PYTHON.md`: Python web app code changes.60- `examples/appinsights.bicep`: Bicep resource example.61- `scripts/appinsights.ps1`: Azure CLI command model for creating the resource.6263## Output template6465```markdown66## Application Insights instrumentation result6768**Status:** instrumented | recommendation only | blocked69**App stack:** `<language, framework, hosting>`70**Instrumentation path:** auto-instrumentation | ASP.NET Core SDK | Node.js SDK | Python SDK | infrastructure only7172| Change | File/resource | Evidence |73| --- | --- | --- |74| `<resource created or code updated>` | `<path or Azure resource>` | `<setting, package, or snippet>` |7576### Configuration77- Application Insights resource group: `<resource group or assumed target>`78- Connection setting location: `<app setting/env var/IaC output>`7980### Validation81- Telemetry startup path checked: <yes/no>82- Secret hardcoding avoided: <yes/no>83```8485## Quality gate8687- [ ] The app's language, framework, and hosting model were identified or an assumption was explicitly stated.88- [ ] Auto-instrumentation was considered before code instrumentation for ASP.NET Core on Azure App Service.89- [ ] Existing Bicep was preferred over ad hoc CLI resource creation when present.90- [ ] The Application Insights connection string or equivalent setting is configured outside source code.91- [ ] The stack-specific bundled reference was used before changing code.92- [ ] The result explains how telemetry can be validated after deployment.