none
How to exclude a specific page or URL from Application insight monitoring RRS feed

  • Question

  • For google AMP implementation, custom java script code is no allowed. But when the page is deployed in Azure app service, the java script code for application insight is injected at the head section which invalidates the page for being AMP. Any solution as how to exclude a particular URL from injecting app insight js code? The application insight is not set up at code level but at server level through Azure app insight.
    Tuesday, November 5, 2019 1:42 PM

Answers

All replies

  • Could you provide the server-side code you are using to inject the JS scripts, minus the AI key?

    If you are doing the injection through one of the server side SDKs, it's likely possible, but I need to know how you are doing the injection to direct you how to do so in your specific case.

    If you are doing it through the app services, then first switching to a code-based instantiation will allow that kind of customization.

    Tuesday, November 5, 2019 4:35 PM
    Moderator
  • By server side I meant to say through Azure portal using "Agent-based application monitoring" at runtime. We have not implemented any code changes for app insights. In app service configuration two keys are added, AI key and APPINSIGHTS_JAVASCRIPT_ENABLED. In Azure, I could not find any settings for customizing Application insights to exclude a particular URL from injecting JS script. Basically, i don't want this JS code to be inserted in one particular URL. 
    Wednesday, November 6, 2019 10:04 AM
  • The advantage of using the app settings is that it's quick and easy to configure. The downside is that it is a standardized implementation. In order to do the customization you are looking for you will need to inject the snippet from your own code so you have control over which pages include it. We have a guide on how to setup the javascript SDK here: https://docs.microsoft.com/en-us/azure/azure-monitor/app/javascript

    You can still use the agent based monitoring for your back end code while using the JS SDK for client side.

    • Marked as answer by AnishKP Wednesday, November 6, 2019 3:59 PM
    Wednesday, November 6, 2019 3:52 PM
    Moderator
  • Thank you. That was very helpful. 
    Wednesday, November 6, 2019 3:59 PM
  • https://docs.microsoft.com/en-us/azure/azure-monitor/app/azure-web-apps#enable-client-side-monitoring-for-net-applications

    Set APPINSIGHTS_JAVASCRIPT_ENABLED = fasle, if you dont want clientside monitoring. There is no option to disable it per page. The setting applies to whole application in that Web App.

    • Marked as answer by AnishKP Wednesday, November 6, 2019 5:10 PM
    Wednesday, November 6, 2019 5:04 PM
  • Thanks Cijo
    Wednesday, November 6, 2019 5:10 PM