# How to configure Azure Application Insights for a Web App in Visual Studio

# Monitor your application with Application Insights

Azure Application insights (opens new window) is part of Azure Monitor (opens new window). You can use it to monitor individual applications, e.g., web applications, and track data including users, page events, errors and calls to dependencies, e.g., databases and APIs.

In this post, we'll use Visual Studio (opens new window) to enable Azure Application Insights (opens new window) for an application.

# Prerequisites

If you want to follow along, you'll need the following:

# Use Visual Studio for Application Insights

We can use Visual Studio to configure Application Insights to work with a web application. Let's try it out.

  1. Open Visual Studio
  2. Choose Create a new project on the splash screen, or through the menu (File > New > Project)
  3. Select ASP NET Core Web App and click Next
  4. Enter a Name for the project
  5. Pick a Location
  6. Click Next
  7. Leave the rest of the settings as they are and click Create
  8. In the Solution Explorer, right-click the project and select "Configure Application Insights..."

(Configure Application Insights in Visual Studio)

  1. You can use the Application Insights SDK without connecting to an Azure instance of Application Insights. We are not going to do that, so select Azure Application Insights and click Next
  2. In the next screen, click the + button to create a new Application Insights resource in Azure
    1. Enter a Name
    2. Select a Resource Group
    3. Pick a Location
    4. Click Create to create the Application Insights resource

(Create Azure Application Insights from Visual Studio)

  1. Click Next to use the Application Insights resource that we've just created
  2. Leave the connection string settings as they are and click Next
  3. In the Summary screen, you can see what Visual Studio will do to configure Application Insights. Click Finish to let Visual Studio configure it

(Application Insights configuration summary)

When the configuration is complete, we can test it. Press F5 to start debugging the application and click on the links in the web app. In the Projects menu of Visual Studio, you can now select Application Insights, which will show all the data that it collected.

(Application Insights telemetry in Visual Studio)

And when you navigate to the Application Insights instance in the Azure portal, you can drill down into all the data, e.g. the page events.

(Application Insights data in the Azure portal)

# Conclusion

Azure Application Insights (opens new window) is a powerful monitoring service for applications. Visual Studio (opens new window) makes it very easy to enable and configure, so that you can start using it instantly. Go and check it out!