title | description | services | keywords | author | ms.author | ms.date | ms.service | ms.custom | ms.topic | manager |
---|---|---|---|---|---|---|---|---|---|---|
Monitor your ASP.NET Web App with Azure Application Insights | Microsoft Docs |
Provides instructions to quickly setup a ASP.NET Web App for monitoring with Application Insights |
application-insights |
mrbullwinkle |
mbullwin |
10/11/2018 |
application-insights |
mvc |
quickstart |
carmonm |
With Azure Application Insights, you can easily monitor your web application for availability, performance, and usage. You can also quickly identify and diagnose errors in your application without waiting for a user to report them. With the information that you collect from Application Insights about the performance and effectiveness of your app, you can make informed choices to maintain and improve your application.
This quickstart shows how to add Application Insights to an existing ASP.NET web application and start analyzing live statistics, which is just one of the various methods you can use to analyze your application. If you do not have a ASP.NET web application, you can create one following the Create a ASP.NET Web App quickstart.
To complete this quickstart:
- Install Visual Studio 2017 with the following workloads:
- ASP.NET and web development
- Azure development
If you don't have an Azure subscription, create a free account before you begin.
-
Open your project in Visual Studio 2017.
-
Select Configure Application Insights from the Project menu. Visual Studio adds the Application Insights SDK to your application.
[!IMPORTANT] The process to add Application Insights varies by ASP.NET template type. If you are using the Empty or Azure Mobile App template select Project > Add Application Insights Telemetry. For all other ASP.NET templates consult the instructions in the step above.
-
Click Get Started (earlier versions of Visual Studio have a Start Free button instead).
-
Select your subscription and click Register.
-
Run your application by either selecting Start Debugging from the Debug menu or by pressing the F5 key.
Application Insights gathers telemetry data for your application regardless of where it's running. Use the following steps to start viewing this data.
-
Open Application Insights by clicking View -> Other Windows -> Application Insights Search. You see the telemetry from your current session.
-
Click on the first request in the list (GET Home/Index in this example) to see the request details. Notice that the status code and response time are both included along with other valuable information about the request.
You can now open Application Insights in the Azure portal to view various details about your running application.
-
Right-click on Connected Services Application Insights folder in Solution Explorer and click Open Application Insights Portal. You see some information about your application and a variety of options.
-
Click on Application map to get a visual layout of the dependency relationships between your application components. Each component shows KPIs such as load, performance, failures, and alerts.
-
Click on the App Analytics icon
on one of the application components. This opens Application Insights Analytics, which provides a rich query language for analyzing all data collected by Application Insights. In this case, a query is generated for you that renders the request count as a chart. You can write your own queries to analyze other data.
-
Return to the Overview page and click on Live Stream. This shows live statistics about your application as it's running. This includes such information as the number of incoming requests, the duration of those requests, and any failures that occur. You can also inspect critical performance metrics such as processor and memory.
If you are ready to host your application in Azure, you can publish it now. Follow the steps described in Create an ASP.NET Web App Quickstart.
-
If you use Visual Studio to add Application Insights monitoring, you can automatically add client-side monitoring. To add client-side monitoring manually to an application add the following JavaScript to your application:
<!--
To collect user behavior analytics about your application,
insert the following script into each page you want to track.
Place this code immediately before the closing </head> tag,
and before any other scripts. Your first data will appear
automatically in just a few seconds.
-->
<script type="text/javascript">
var appInsights=window.appInsights||function(a){
function b(a){c[a]=function(){var b=arguments;c.queue.push(function(){c[a].apply(c,b)})}}var c={config:a},d=document,e=window;setTimeout(function(){var b=d.createElement("script");b.src=a.url||"https://az416426.vo.msecnd.net/scripts/a/ai.0.js",d.getElementsByTagName("script")[0].parentNode.appendChild(b)});try{c.cookie=d.cookie}catch(a){}c.queue=[];for(var f=["Event","Exception","Metric","PageView","Trace","Dependency"];f.length;)b("track"+f.pop());if(b("setAuthenticatedUserContext"),b("clearAuthenticatedUserContext"),b("startTrackEvent"),b("stopTrackEvent"),b("startTrackPage"),b("stopTrackPage"),b("flush"),!a.disableExceptionTracking){f="onerror",b("_"+f);var g=e[f];e[f]=function(a,b,d,e,h){var i=g&&g(a,b,d,e,h);return!0!==i&&c["_"+f](a,b,d,e,h),i}}return c
}({
instrumentationKey:"<your instrumentation key>"
});
window.appInsights=appInsights,appInsights.queue&&0===appInsights.queue.length&&appInsights.trackPageView();
</script>
To learn more, visit the GitHub repository for our open-source JavaScript SDK.
In this quick start, you’ve enabled your application for monitoring by Azure Application Insights. Continue to the tutorials to learn how to use it to monitor statistics and detect issues in your application.
[!div class="nextstepaction"] Azure Application Insights tutorials