Enable the .NET Profiler for Azure App Service apps
Application Insights Profiler for .NET is preinstalled as part of the Azure App Service runtime. You can run Profiler on ASP.NET and ASP.NET Core apps running 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.
- Is only supported on Windows-based web apps.
To enable .NET Profiler on Linux, walk through the ASP.NET Core Azure Linux web apps instructions.
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
In the Azure portal, go to your App Service instance.
In the left menu, select Settings > Configuration.
Select the General settings tab.
Verify that Always on > On is selected.
Note
If the Always on toggle 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
You can enable Profiler either when:
- Your Application Insights resource and App Service resource are in the same subscription, or
- 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, select Monitoring > Application Insights.
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.
Verify that Collection level > Recommended is selected.
Under Profiler, select On.
If you chose the Basic collection level earlier, the Profiler setting is disabled.
Select Apply > 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 by creating app settings for your App Service instance. You can automate the creation of these settings by using a template or other means. Here are the settings you need to enable Profiler.
App setting | Value |
---|---|
APPLICATIONINSIGHTS_CONNECTION_STRING | Unique value from your App Insights resource. |
APPINSIGHTS_PROFILERFEATURE_VERSION | 1.0.0 |
DiagnosticServices_EXTENSION_VERSION | ~3 |
Set these values by using:
Enable .NET Profiler for regional clouds
Currently, the only regions that require endpoint modifications are Azure Government and Microsoft Azure operated by 21Vianet.
App setting | US Government Cloud | China Cloud |
---|---|---|
ApplicationInsightsProfilerEndpoint | https://profiler.monitor.azure.us |
https://profiler.monitor.azure.cn |
ApplicationInsightsEndpoint | https://dc.applicationinsights.us |
https://dc.applicationinsights.azure.cn |
Enable Microsoft Entra authentication for profile ingestion
Application Insights Profiler for .NET supports Microsoft Entra authentication for profile ingestion. For all profiles of your application to be ingested, your application must be authenticated 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_STRING Authorization=AAD
For user-assigned identity:
App setting Value APPLICATIONINSIGHTS_AUTHENTICATION_STRING Authorization=AAD;ClientId={Client id of the User-Assigned Identity}
Disable the .NET Profiler
To stop or restart Profiler for an individual app's instance:
Under Settings on the left pane, select WebJobs.
Select the webjob named
ApplicationInsightsProfiler3
.Select Stop.
Select Yes to confirm.
We recommend that you have Profiler enabled on all your apps to discover any performance issues as early as possible.
You can delete Profiler's files when you use WebDeploy to deploy changes to your web application. You can prevent the deletion by excluding the App_Data folder from being deleted during deployment.
Next steps
- 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