Search code examples
asp.netazurevs-web-site-projectazure-application-insights

Azure Application Insights and Web Site projects


Is it possible to add Application Insights to a Web Site project type?

In Visual Studio, the following context menu is available for Web Application projects but is missing for Web Site projects.

enter image description here


Solution

  • Just want to share what I ended up with doing. First of all, it seems to work like a charm.

    The Application Insight is implemented as an ASP.NET Module, so in order to hook it up for Web Site project you need to do the following:

    1. Add Microsoft.ApplicationInsights.Web NuGet package
    2. Register AI module in web.config

      <modules runAllManagedModulesForAllRequests="true">
        <remove name="ApplicationInsightsWebTracking" />
        <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
      </modules>
      
    3. Make sure you have ApplicationInsights.config in Web Site base directory (along with web.config) - it defines which telemetry you going to be collecting