Bilješka
Pristup ovoj stranici zahtijeva provjeru vjerodostojnosti. Možete pokušati da se prijavite ili promijenite direktorije.
Pristup ovoj stranici zahtijeva provjeru vjerodostojnosti. Možete pokušati promijeniti direktorije.
Application Insights Profiler for .NET captures traces of your live app to show which requests are slow and which lines of code cause the slowdown. When your app runs slower than expected in production, Profiler helps you find the bottleneck instead of guessing.
Profiler is preinstalled as part of the Azure App Service runtime. This article shows you how to enable it for ASP.NET and ASP.NET Core apps that run on App Service by using the Basic service tier or higher.
Codeless installation of Application Insights Profiler for .NET follows the .NET Core support policy. Azure supports it only on Windows-based web apps. To enable .NET Profiler on Linux, see Enable the .NET Profiler for Azure App Service apps in Linux.
Prerequisites
- An Azure App Service ASP.NET/ASP.NET Core app.
- An Application Insights resource connected to your App Service app.
Verify the "Always on" setting is enabled
Profiler runs as a continuous WebJob, so your app must keep running even when it's idle. Verify that the Always On setting is enabled before you enable Profiler.
In the Azure portal, go to your App Service instance.
In the left menu, select Settings > Configuration.
Select General settings.
Verify that Always on is set to On.
Note
If Always On is disabled, upgrade your App Service web app to run on Basic tier or higher.
Select Save if you made changes.
Enable Application Insights and the .NET Profiler
Enable Profiler in either of these scenarios:
- Your Application Insights resource and App Service resource are in the same subscription
- Your Application Insights resource and App Service resource are in separate subscriptions
For Application Insights and App Service in the same subscription
If your Application Insights resource is in the same subscription as your instance of App Service:
In the left menu of your App Service instance, select Monitoring > Application Insights.
Select Turn on Application Insights.
In the Application Insights setting page, under Application Insights, select Enable.
Verify that you connected an Application Insights resource to your app.
Scroll down and select the .NET or .NET Core tab, depending on your app.
For Collection level, select Recommended.
Under Profiler and Code Optimizations, select On. If you chose the Basic collection level earlier, the Profiler setting is disabled.
Select Apply, and then Yes to confirm.
For Application Insights and App Service in different subscriptions
If your Application Insights resource is in a different subscription from your instance of App Service, you need to enable the Profiler for .NET manually. Enable it by creating app settings for your App Service instance. You can automate creating these settings by using a template or other means. Here are the settings you need to enable Profiler.
| App setting | Value |
|---|---|
APPLICATIONINSIGHTS_CONNECTION_STRING |
Get this value from the Overview page for your Application Insights resource. |
APPINSIGHTS_PROFILERFEATURE_VERSION |
1.0.0 |
DiagnosticServices_EXTENSION_VERSION |
~3 |
Set these values by using:
Enable .NET Profiler for sovereign clouds
If your app runs in a sovereign cloud, add app settings that point Profiler to the correct regional endpoints. Make these modifications only for Azure Government and Microsoft Azure operated by 21Vianet.
| App setting | Azure Government | Microsoft Azure operated by 21Vianet |
|---|---|---|
ApplicationInsightsProfilerEndpoint |
https://profiler.monitor.azure.us |
https://profiler.monitor.azure.cn |
ApplicationInsightsEndpoint |
https://{region}.in.applicationinsights.azure.us |
https://{region}.in.applicationinsights.azure.cn |
Compare Azure Public and Azure Government endpoints for common Azure services.
Enable Microsoft Entra authentication for profile ingestion
Application Insights Profiler for .NET supports Microsoft Entra authentication for profile ingestion. For the Profiler agent to ingest all profiles of your application, your application must authenticate and provide the required application settings to the Profiler agent.
Profiler only supports Microsoft Entra authentication when you reference and configure Microsoft Entra ID by using the Application Insights SDK in your application.
To enable Microsoft Entra ID for profile ingestion:
Create and add the managed identity to authenticate against your Application Insights resource to your App Service:
Configure and enable Microsoft Entra ID in your Application Insights resource.
Add the following application setting to let the Profiler agent know which managed identity to use.
For system-assigned identity:
App setting Value APPLICATIONINSIGHTS_AUTHENTICATION_STRINGAuthorization=AADFor user-assigned identity:
App setting Value APPLICATIONINSIGHTS_AUTHENTICATION_STRINGAuthorization=AAD;ClientId={Client id of the User-Assigned Identity}
Disable the .NET Profiler
To stop or restart Profiler for an individual app's instance:
In the Azure portal, go to your App Service instance.
Under Settings on the left menu, select WebJobs.
Select the WebJob named
ApplicationInsightsProfiler3.Select the Stop icon.
Select Stop to confirm.
Keep Profiler enabled on all your apps to discover any performance issues as early as possible.
Prevent Profiler files from being deleted during Web Deploy
When you use Web Deploy to deploy changes to your web application, the deployment can delete Profiler's files. To prevent the deletion, exclude the App_Data folder from deletion during deployment.
Related content
- Learn how to generate load and view the .NET Profiler traces
- Learn how to use the Code Optimizations feature alongside the Application Insights Profiler for .NET