How to disable adaptive sampling in Application Insights for .NET Core Web App using environment variables?
We are running a .NET Core API (written in C#) hosted in Azure App Service, and using Application Insights for telemetry and diagnostic logging. We’ve been missing certain telemetry entries when under load, and suspect this is due to adaptive sampling being enabled by default.
I’ve found documentation suggesting that adaptive sampling can be disabled by setting an environment variable like: (https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-standalone-sampling-overrides)
APPINSIGHTS_SAMPLING_PERCENTAGE = 100
I added this as an environment variable under Configuration > Application Settings in the Azure Web App and restarted the service before the weekend. However, I’m still seeing the following message in Application Insights:
“Data received from your application is being sampled to reduce the volume of telemetry data retained; only sampled documents will be returned. The sampling may be applied by the Application Insights SDK or on ingestion by Application Insights.”
Additionally, the sampling rate under the Usage and Costs blade in Application Insights to 100%, but I understand that this doesn’t impact SDK-level sampling.
I’m now wondering:
- Are enviroment variables like APPINSIGHTS_SAMPLING_PERCENTAGE even supported for .NET Core SDKs or does this just apply to Java? Because the only suppor doc mentioning using an Envirpment Variable appears to be for Java.
- Or must sampling be disabled explicitly in code for dotnetcore bassed apps?
- Is there an alternative environment variable that applies to .NET Core (not Java/Node)?
My goal is to disable adaptive sampling without changing the app code so we can dynamically control this through configuration only.