Appinsight setup without auto instrumentation

Oussama Dhouioui 20 Reputation points Microsoft Employee
2025-04-11T15:45:43.8266667+00:00

By default if you have an app service and you set up appinsight for it. Auto instrumentation is enabled.

I'd like to disable it but I don't see in bicep provider any param for appinsight to do that :

https://learn.microsoft.com/en-us/azure/templates/microsoft.insights/components?pivots=deployment-language-bicep ?

Can you please advise?

I wrote my custom telemetry in my app and having auto instrumentation enabled will result in duplicated logs?

I want the infra written with bicep!

Thanks in advance!

Blazor Training
Blazor Training
Blazor: A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.Training: Instruction to develop new skills.
31 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Pradeep M 8,185 Reputation points Microsoft External Staff
    2025-04-14T03:27:58.9733333+00:00

    Hi Oussama Dhouioui,

    Thank you for reaching out to Microsoft Q & A forum. 

    To disable auto instrumentation in Application Insights when using Bicep, there's no direct property for this in the Bicep schema. However, you can manage this in the following ways: 

    1.Disable Auto Instrumentation in App Service: 

    Auto-instrumentation can be disabled by adjusting the APPINSIGHTS INSTRUMENTATIONKEY environment variable in the App Service settings, ensuring that the automatic tracking isn’t enabled. 

    2.Custom Telemetry: 

    When using custom telemetry, ensure that automatic tracking for dependencies, requests, and exceptions is disabled within the SDK configuration. This will prevent any duplication of logs. 

    3.Bicep Template Example: 

    Below is a sample Bicep template for deploying Application Insights: 

    resource appInsights 'Microsoft.Insights/components@2020-02-02' = {
      name: 'myAppInsights'
      location: 'East US'
      kind: 'web'
      properties: {
        Application_Type: 'web'
        RetentionInDays: 30
        SamplingPercentage: 100
      }
    }
    
    

    By following these steps, you can configure your Application Insights without enabling auto-instrumentation, ensuring that your custom telemetry remains the primary source for monitoring. 

    If the issue persists, please share the relevant code snippets so we can provide more targeted assistance.     

    If you have found the answer provided to be helpful, please click on the "Accept answer/Upvote" button so that it is useful for other members in the Microsoft Q&A community.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.