Skip to content
Get Started for Free

Application Insights

Azure Application Insights is an application performance management (APM) service for monitoring live applications. It automatically collects request rates, response times, failure rates, and dependency traces, surfacing them in a unified monitoring experience. Application Insights is commonly used to diagnose production issues, track custom business metrics, and set up availability alerts for distributed applications. For more information, see What is Application Insights?.

LocalStack for Azure provides a local environment for building and testing applications that make use of Azure Application Insights. The supported APIs are available on our API Coverage section, which provides information on the extent of Application Insights’ integration with LocalStack.

This guide walks you through creating an Application Insights component and retrieving its instrumentation key. The Azure CLI commands below use the application-insights extension; it is installed automatically the first time you run an az monitor app-insights command (Azure CLI 2.71.0 or later).

Launch LocalStack using your preferred method. For more information, see Introduction to LocalStack for Azure. Once the container is running, enable Azure CLI interception by running:

Terminal window
azlocal start-interception

This command points the az CLI away from the public Azure management REST API and toward the LocalStack for Azure emulator API. To revert this configuration, run:

Terminal window
azlocal stop-interception

This reconfigures the az CLI to send commands to the official Azure management REST API.

Create a resource group to hold all resources created in this guide:

Terminal window
az group create --name rg-insights-demo --location westeurope
Output
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-insights-demo",
"location": "westeurope",
"name": "rg-insights-demo",
"properties": { "provisioningState": "Succeeded" },
"type": "Microsoft.Resources/resourceGroups"
}

Create an Application Insights component in the resource group where you intend to emit telemetry (--workspace, for a workspace-based component linked to Log Analytics, is optional and omitted here).

Terminal window
az monitor app-insights component create \
--app my-app-insights \
--resource-group rg-insights-demo \
--location westeurope \
--kind web \
--application-type web
Output
{
"appId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"connectionString": "InstrumentationKey=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx;IngestionEndpoint=https://westeurope.in.applicationinsights.azure.com/",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-insights-demo/providers/Microsoft.Insights/components/my-app-insights",
"instrumentationKey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"kind": "web",
"location": "westeurope",
"name": "my-app-insights",
"provisioningState": "Succeeded",
"resourceGroup": "rg-insights-demo",
"type": "Microsoft.Insights/components"
...
}

There is no az monitor app-insights component list command in the Azure CLI. Retrieve one component with component show, and list all Application Insights components in the resource group with az resource list and the Microsoft.Insights/components resource type:

Terminal window
az monitor app-insights component show \
--app my-app-insights \
--resource-group rg-insights-demo
Output
{
"appId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-insights-demo/providers/Microsoft.Insights/components/my-app-insights",
"instrumentationKey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"kind": "web",
"location": "westeurope",
"name": "my-app-insights",
"provisioningState": "Succeeded",
"resourceGroup": "rg-insights-demo",
"type": "Microsoft.Insights/components"
...
}
Terminal window
az resource list \
--resource-group rg-insights-demo \
--resource-type Microsoft.Insights/components
Output
[
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-insights-demo/providers/Microsoft.Insights/components/my-app-insights",
"name": "my-app-insights",
"resourceGroup": "rg-insights-demo",
"location": "westeurope",
"type": "Microsoft.Insights/components"
}
]

Retrieve the current billing features and daily data volume cap for the component:

Terminal window
az monitor app-insights component billing show \
--app my-app-insights \
--resource-group rg-insights-demo
Output
{
"currentBillingFeatures": ["Basic"],
"dataVolumeCap": {
"cap": 100.0,
"maxHistoryCap": 1000.0,
"resetTime": 0,
"warningThreshold": 90
}
}

Update the daily data volume cap to limit ingestion costs:

Terminal window
az monitor app-insights component billing update \
--app my-app-insights \
--resource-group rg-insights-demo \
--cap 100
Output
{
"currentBillingFeatures": ["Basic"],
"dataVolumeCap": {
"cap": 100.0,
"maxHistoryCap": 1000.0,
"resetTime": 0,
"warningThreshold": 90
}
}

Delete the resource and confirm it no longer appears when listing Microsoft.Insights/components in the resource group:

Terminal window
az monitor app-insights component delete \
--app my-app-insights \
--resource-group rg-insights-demo
Terminal window
az resource list \
--resource-group rg-insights-demo \
--resource-type Microsoft.Insights/components
Output
[]
  • Component lifecycle: Create, show, and delete Application Insights components; discover instances in a resource group with az resource list and --resource-type Microsoft.Insights/components (see Azure CLI — az monitor app-insights component).
  • Instrumentation key generation: Each component is assigned an instrumentation key returned on creation.
  • App ID assignment: Each component is assigned a unique application ID (for example properties.AppId / appId in CLI output).
  • Billing feature configuration: Get and update billing features such as daily data volume caps (currentBillingFeatures, dataVolumeCap); see Azure CLI — component billing.
  • Application type (--application-type / Application_Type): Accepted values documented for the CLI are web and other (default web).
  • Kind (--kind): Typical values web, ios, other, store, java, phone (free-form string for UI customization; see Azure CLI — component create).
  • No telemetry ingestion: The Application Insights SDK endpoint (/v2/track) is not emulated. Telemetry sent from instrumented applications is not stored or queryable.
  • No Live Metrics stream: The Live Metrics (QuickPulse) endpoint is not emulated.
  • No Logs (KQL) queries: Running queries via az monitor app-insights query (KQL over stored application data) is not supported.
  • No transaction search: Individual telemetry records are not stored or searchable.
  • No availability tests via this component: Availability tests are separate Microsoft.Insights/webtests resources (CLI group web-test), not capabilities of an Application Insights component alone.
  • No continuous export: Continuous export to Storage is not supported.

The following sample demonstrates how to use Azure Application Insights with LocalStack for Azure:

OperationImplemented
Page 1 of 0
Was this page helpful?