Why does Application Insights Diagnostic Setting Recreate Itself Automatically After Deletion?

Daniel-4204 330 Reputation points
2026-07-01T19:01:28.0766667+00:00

Summary

We had been experiencing duplicate telemetry in Application Insights and our Log Analytics workspace for an extended period, likely since approximately April 2024. After significant investigation we identified and resolved the root cause, however a secondary issue has now emerged where the diagnostic setting we deleted as part of the fix is being automatically recreated by an unknown process every 1 to 3 hours. We have deleted it 4 times over the last 2 days and it continues to return.

Background and Timeline

For an extended period we observed duplicate telemetry records appearing in both Application Insights and our Log Analytics workspace. Each logical request, exception, event, dependancy, etc... was producing two identical telemetry records with different itemId values but the same operation_Id, id (span id), duration, and cloud_RoleInstance. This indicated the same single span was being exported twice rather than two separate requests being made.

During this period we also renamed our Application Insights resources from the legacy ai- prefix naming convention to the current Microsoft recommended appi- prefix. This rename itself did not cause the duplicates but brought renewed attention to the telemetry configuration.

We investigated and ruled out the following as root causes:

Duplicate SDK registration or instrumentation in application code (no duplicates present)

Legacy APPINSIGHTS_INSTRUMENTATIONKEY or APPLICATIONINSIGHTS_CONNECTION_STRING environment variables on the App Service (now removed).

Auto-instrumentation enabled via the App Service Application Insights portal blade (now removed).

Platform-level injection via DOTNET_STARTUP_HOOKS, CORECLR_ENABLE_PROFILING, CORECLR_PROFILER, or ASPNETCORE_HOSTINGSTARTUPASSEMBLIES environment variables. (now removed).

Kudu site extensions or Application Insights profiler WebJobs (none present)

Network path differences between environments (not applicable)

Duplicate OTel span creation confirmed by comparing span id values across duplicate records (no duplicates)

Root Cause Identified and Resolved (Explained here: https://learn.microsoft.com/en-us/answers/questions/1837830/possible-reasons-for-double-entries-in-app-insight?page=1&orderby=helpful#answers)

We discovered a Microsoft documentation note stating that for workspace-based Application Insights resources, the diagnostic setting destination cannot be the same Log Analytics workspace the Application Insights resource is natively linked to, as this causes duplicate ingestion.

Our Application Insights resource is workspace-based and natively writes all telemetry to our Log Analytics workspace. We also had a diagnostic setting named Events on the same resource configured to export to that same Log Analytics workspace. This diagnostic setting predated our workspace-based migration and was originally configured when the resource was classic App Insights, at which time, Diagnostic Setting method was the only mechanism for getting telemetry into the workspace. When our resource to workspace-based, which we believe occurred around April 2024/2025 based on Microsoft's documented forced migration timeline, the native pipeline began writing directly to the workspace and the existing diagnostic setting began producing a second copy of every event. (At least we believe).

Deleting the Events diagnostic setting immediately resolved the duplicate telemetry. No duplicates have appeared since deletion. But the diagnostic setting keeps coming back. (Note: We named it "Events"... but the setting contains most all log types available).

User's image

Current Issue

After deleting the Events diagnostic setting, it is being recreated automatically without any manual intervention. We have deleted it 4 times over the last 2 days and it reappears within 1 to 3 hours each time. We have attempted to identify the source via Azure Activity Log and PowerShell using Get-AzLog and az monitor activity-log list, however these commands return no results for diagnostic setting operations on this resource despite the portal Activity Log export confirming the events exist. The portal export shows only deletions initiated by our own admin account but does not capture the creation events responsible for the recreation, suggesting the creating identity may not be visible in standard activity log exports or may be a platform-level process.

What We Need

We need Microsoft to identify what process or identity is recreating the Events diagnostic setting on our Application Insights resource after deletion and provide guidance on how to permanently prevent it from being recreated. Or need confirmation on whether this is expected platform behavior tied to the workspace-based migration, and if so, what the supported remediation path is.

Perhaps, the Events diagnostic setting is supposed to be self-present? Which is why it comes back?

Azure Monitor
Azure Monitor

An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.


Answer accepted by question author
Suchitra Suregaunkar 16,780 Reputation points Microsoft External Staff Moderator
2026-07-14T16:14:55.2533333+00:00

Hello Daniel-4204

Deletion of diagnostic setting via portal/API indicates success. but, settings return back after 20mins, this might be due to orphaned diagnostic settings cases.

When an Azure resource is deleted via the Azure portal, REST API, Azure PowerShell, Azure CLI or other supported Azure SDK any associated diagnostic settings are not deleted though they are no longer accessible.  This is expected behavior based on the design of diagnostic settings.

The same can occur if the resource is moved across Resource Groups or Subscriptions.

The diagnostic setting is an extension proxy resource of the Azure resource to which it is associated so the delete action against the Azure resource does not cascade to the related diagnostic settings.  Since the diagnostic setting is an extension of an Azure resource, it cannot be referenced without the related Azure resource existing making it inaccessible though still existing (orphaned).

 

This design is called out in article [https://learn.microsoft.com/en-us/azure/azure-monitor/essentials/diagnostic-settings].

 There are two solutions available:

Have the customer recreate the Azure resource under the same subscription and resource group using the same resource name.  This will create the Azure resource identifier that then makes the associated diagnostic settings accessible once again where they can be deleted and then the Azure resource can be deleted again.

Submit a request to the Azure Monitor product group that owns diagnostic settings requesting that they remove the orphaned diagnostic settings. 

Steps performed:

  1. Created a new temporary Application Insights resource under the former resource name, <PII Removed>api-dev, in the same subscription and resource group.
  2. Created a Diagnostic Setting named "Events" on the temporary <PII Removed>api-dev resource.
  3. Deleted the "Events" Diagnostic Setting from <PII Removed>api-dev
  4. Deleted the "Events" Diagnostic Setting from the temporary <PII Removed>api-dev resource.
  5. Deleted the temporary <PII Removed>api-dev Application Insights resource entirely.

After waiting 30 minutes, well past the consistent 30 minute regeneration interval observed in every prior cycle, the "Events" Diagnostic Setting has NOT returned to <PII Removed>

Thanks,
Suchitra.

Was this answer helpful?

2 people found this answer helpful.

0 additional answers

Sort by: Oldest

Your answer

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