Start monitoring your ASP.NET Web Application
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 an ASP.NET web application, you can create one following the Create an ASP.NET Web App quickstart.
To complete this quickstart:
- Install Visual Studio 2019 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.
Enable Application Insights
Open your project in Visual Studio 2019.
Select Configure Application Insights from the Project menu. Visual Studio adds the Application Insights SDK to your application.
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.
Select Project > Manage NuGet Packages > Package source: nuget.org > Update the Application Insights SDK packages to the latest stable release.
Run your application by either selecting Start Debugging from the Debug menu or by pressing the F5 key.
Confirm app configuration
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.
Start monitoring in the Azure portal
You can now open Application Insights in the Azure portal to view various details about your running application.
Expand the Connected Services folder (cloud and plug icon) in the Solution Explorer then right-click on the Application Insights folder 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 View in Logs (Analytics) on one of the application components. This opens Logs (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.
Click on Live Metrics Stream on the left under investigate. 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.
- External step-by-step video about configuring Application Insights with a .NET application from scratch.
Clean up resources
When you are done testing, you can delete the resource group and all related resources. To do so follow the steps below.
- From the left-hand menu in the Azure portal, click Resource groups and then click myResourceGroup.
- On your resource group page, click Delete, type myResourceGroup in the text box, and then click Delete.
In this quickstart, 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.