Microsoft is expanding .NET developers’ toolset with enhancements to Code Optimizations. This feature is part of Azure Monitor offering and now works with the .NET Profiler in Application Insights to automatically detect CPU, memory, and threading issues in production apps and give code‑level recommendations to fix them.
Code Optimizations is an AI-based service running on Azure Application Insights that uses telemetry gathered by the Application Insights Profiler for .NET to analyse runtime behaviour, find performance bottlenecks down to individual methods, and provide actionable suggestions. Developers can view aggregated data over time (defaulting to a rolling 24‑hour window, with history up to 30 days) for their production and non-production environments.

Code Optimization suggested actions to improve code performance (source: Microsoft)
The enhanced features in Code Optimizations are the detection of issues that block threads, direct GitHub Copilot task assignment from the overview page, and preview support for OpenTelemetry collectors instead of Application Insights proprietary ones.
When profiling is enabled in the application, the .NET Profiler is triggered in three ways: as a sampling trigger (once per hour for 30 seconds), when CPU crosses 80% threshold or when memory usage crosses 80% threshold. These parameters are configurable, while the profiler trace process is designed to minimise user impact.
Developers can see Code Optimizations’ consolidated recommendations across subscriptions and resources. When inspecting code issues, they can use Visual Studio or VS Code extensions (integrated with GitHub Copilot) to suggest or even generate fixes, or create GitHub issues assigned to the Copilot agent.
There is some overhead: with the profiler running, developers can expect between 5‑15% CPU and memory impact on average. The storage of profiler trace data incurs no extra cost in Azure, and the data is retained for 15 days.
Enabling the .NET Profiler is relatively straightforward for many Azure services. App Service and Functions (on appropriate plans), Virtual Machines, Virtual Machine Scale Sets, Azure Kubernetes Service, Container Apps, Service Fabric and containers are all supported. In some cases, there is no need for extra code to support Code Optimizations.
Developers need at least the Basic tier for Azure Web Application profiling. There is only one profiler active per web app. The regional availability aligns with Application Insights regions.
Microsoft elicits feedback from developers using Code Optimizations to guide future enhancements. The feedback form is available here.