Create an Application Insights resource
Caution
This article applies to Application Insights Classic resources, which are no longer recommended.
The information in this article is stale and won't be updated.
Transition to workspace-based Application Insights to take advantage of new capabilities.
Application Insights displays data about your application in an Azure resource. Creating a new resource is part of setting up Application Insights to monitor a new application. After you've created your new resource, you can get its instrumentation key and use it to configure the Application Insights SDK. The instrumentation key links your telemetry to the resource.
Important
On February 29, 2024, support for classic Application Insights will end. Transition to workspace-based Application Insights to take advantage of new capabilities. Newer regions introduced after February 2021 don't support creating classic Application Insights resources.
Note
On March 31, 2025, support for instrumentation key ingestion will end. Instrumentation key ingestion will continue to work, but we'll no longer provide updates or support for the feature. Transition to connection strings to take advantage of new capabilities.
Sign in to Azure
If you don't have an Azure subscription, create a free account before you begin.
Create an Application Insights resource
Sign in to the Azure portal and create an Application Insights resource.
Settings | Value | Description |
---|---|---|
Name | Unique value |
Name that identifies the app you're monitoring. |
Resource group | myResourceGroup |
Name for the new or existing resource group to host Application Insights data. |
Region | East US |
Select a location near you or near where your app is hosted. |
Resource mode | Classic or Workspace-based |
Workspace-based resources allow you to send your Application Insights telemetry to a common Log Analytics workspace. For more information, see Workspace-based Application Insights resources. |
Note
You can use the same resource name across different resource groups, but it can be beneficial to use a globally unique name. If you plan to perform cross-resource queries, using a globally unique name simplifies the required syntax.
Enter the appropriate values in the required fields. Select Review + create.
After your app is created, a new pane displays performance and usage data about your monitored application.
Copy the instrumentation key
The instrumentation key identifies the resource that you want to associate with your telemetry data. You need to copy the instrumentation key and add it to your application's code.
Install the SDK in your app
Install the Application Insights SDK in your app. This step depends heavily on the type of your application.
Use the instrumentation key to configure the SDK that you install in your application.
The SDK includes standard modules that send telemetry, so you don't have to write any more code. To track user actions or diagnose issues in more detail, use the API to send your own telemetry.
Create a resource automatically
Use PowerShell or the Azure CLI to create a resource automatically.
PowerShell
Create a new Application Insights resource.
New-AzApplicationInsights [-ResourceGroupName] <String> [-Name] <String> [-Location] <String> [-Kind <String>]
[-Tag <Hashtable>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
Example
New-AzApplicationInsights -Kind java -ResourceGroupName testgroup -Name test1027 -location eastus
Results
Id : /subscriptions/{subid}/resourceGroups/testgroup/providers/microsoft.insights/components/test1027
ResourceGroupName : testgroup
Name : test1027
Kind : web
Location : eastus
Type : microsoft.insights/components
AppId : 8323fb13-32aa-46af-b467-8355cf4f8f98
ApplicationType : web
Tags : {}
CreationDate : 10/27/2017 4:56:40 PM
FlowType :
HockeyAppId :
HockeyAppToken :
InstrumentationKey : 00000000-aaaa-bbbb-cccc-dddddddddddd
ProvisioningState : Succeeded
RequestSource : AzurePowerShell
SamplingPercentage :
TenantId : {subid}
For the full PowerShell documentation for this cmdlet, and to learn how to retrieve the instrumentation key, see the Azure PowerShell documentation.
Azure CLI (preview)
To access the preview Application Insights Azure CLI commands, you first need to run:
az extension add -n application-insights
If you don't run the az extension add
command, you see an error message that states: az : ERROR: az monitor: 'app-insights' is not in the 'az monitor' command group. See 'az monitor --help'.
Run the following command to create your Application Insights resource:
az monitor app-insights component create --app
--location
--resource-group
[--application-type]
[--kind]
[--tags]
Example
az monitor app-insights component create --app demoApp --location westus2 --kind web --resource-group demoRg --application-type web
Results
az monitor app-insights component create --app demoApp --location eastus --kind web --resource-group demoApp --application-type web
{
"appId": "87ba512c-e8c9-48d7-b6eb-118d4aee2697",
"applicationId": "demoApp",
"applicationType": "web",
"creationDate": "2019-08-16T18:15:59.740014+00:00",
"etag": "\"0300edb9-0000-0100-0000-5d56f2e00000\"",
"flowType": "Bluefield",
"hockeyAppId": null,
"hockeyAppToken": null,
"id": "/subscriptions/{subid}/resourceGroups/demoApp/providers/microsoft.insights/components/demoApp",
"instrumentationKey": "00000000-aaaa-bbbb-cccc-dddddddddddd",
"kind": "web",
"location": "eastus",
"name": "demoApp",
"provisioningState": "Succeeded",
"requestSource": "rest",
"resourceGroup": "demoApp",
"samplingPercentage": null,
"tags": {},
"tenantId": {tenantID},
"type": "microsoft.insights/components"
}
For the full Azure CLI documentation for this command, and to learn how to retrieve the instrumentation key, see the Azure CLI documentation.
Override default endpoints
Warning
Don't modify endpoints. Transition to connection strings to simplify configuration and eliminate the need for endpoint modification.
To send data from Application Insights to certain regions, you need to override the default endpoint addresses. Each SDK requires slightly different modifications, all of which are described in this article.
These changes require you to adjust the sample code and replace the placeholder values for QuickPulse_Endpoint_Address
, TelemetryChannel_Endpoint_Address
, and Profile_Query_Endpoint_address
with the actual endpoint addresses for your specific region. The end of this article contains links to the endpoint addresses for regions where this configuration is required.
Note
On March 31, 2025, support for instrumentation key ingestion will end. Instrumentation key ingestion will continue to work, but we'll no longer provide updates or support for the feature. Transition to connection strings to take advantage of new capabilities.
SDK code changes
Note
The applicationinsights.config file is automatically overwritten anytime an SDK upgrade is performed. After you perform an SDK upgrade, be sure to reenter the region-specific endpoint values.
<ApplicationInsights>
...
<TelemetryModules>
<Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryModule, Microsoft.AI.PerfCounterCollector">
<QuickPulseServiceEndpoint>Custom_QuickPulse_Endpoint_Address</QuickPulseServiceEndpoint>
</Add>
</TelemetryModules>
...
<TelemetrySinks>
<Add Name = "default">
<TelemetryChannel>
<EndpointAddress>TelemetryChannel_Endpoint_Address</EndpointAddress>
</TelemetryChannel>
</Add>
</TelemetrySinks>
...
<ApplicationIdProvider Type="Microsoft.ApplicationInsights.Extensibility.Implementation.ApplicationId.ApplicationInsightsApplicationIdProvider, Microsoft.ApplicationInsights">
<ProfileQueryEndpoint>Profile_Query_Endpoint_address</ProfileQueryEndpoint>
</ApplicationIdProvider>
...
</ApplicationInsights>
Regions that require endpoint modification
Currently, the only regions that require endpoint modifications are Azure Government and Azure China.
Region | Endpoint name | Value |
---|---|---|
Azure China | Telemetry Channel | https://dc.applicationinsights.azure.cn/v2/track |
Azure China | QuickPulse (Live Metrics) | https://live.applicationinsights.azure.cn/QuickPulseService.svc |
Azure China | Profile Query | https://dc.applicationinsights.azure.cn/api/profiles/{0}/appId |
Azure Government | Telemetry Channel | https://dc.applicationinsights.us/v2/track |
Azure Government | QuickPulse (Live Metrics) | https://quickpulse.applicationinsights.us/QuickPulseService.svc |
Azure Government | Profile Query | https://dc.applicationinsights.us/api/profiles/{0}/appId |
If you currently use the Application Insights REST API, which is normally accessed via api.applicationinsights.io
, you need to use an endpoint that's local to your region.
Region | Endpoint name | Value |
---|---|---|
Azure China | REST API | api.applicationinsights.azure.cn |
Azure Government | REST API | api.applicationinsights.us |
Next steps
- Use Diagnostic Search.
- Explore metrics.
- Write Log Analytics queries.
- To learn more about the custom modifications for Azure Government, see the detailed guidance for Azure monitoring and management.
- To learn more about Azure China, see the Azure China Playbook.