languages | products | page_type | name | urlFragment | description | |||
---|---|---|---|---|---|---|---|---|
|
|
sample |
Azure Monitor Application Insights Quickstart for ASP.NET Core |
azure-monitor-application-insights-quickstart |
A sample ASP.NET Core app that demonstrates basic instrumentation for Azure Monitor Application Insights. |
This sample ASP.NET Core application was created with dotnet new razor
. After that, the following changes were made:
- The Application Insights SDK was added to the project with
dotnet add package Microsoft.ApplicationInsights.AspNetCore --version 2.17.0
. - A configuration value for
ApplicationInsights:InstrumentationKey
was added to appsettings.json. services.AddApplicationInsightsTelemetry();
was added to theConfigureServices
method of Startup.cs.@inject Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet JavaScriptSnippet
was added to Pages/_ViewImports.cshtml.@Html.Raw(JavaScriptSnippet.FullScript)
was added to the<head>
element in Pages/Shared/_Layout.cshtml.
- An Azure subscription.
- An active Azure Monitor Application Insights resource.
Replace the placeholder ApplicationInsights:InstrumentationKey
value in appsettings.json with your actual instrumentation key.
dotnet run
As you use the app, telemetry will be ingested to Application Insights within a few minutes. You can verify the connection using Live Metrics.