Monitor Azure App Service performance
In the Azure portal you can set up application performance monitoring for your web apps, mobile back ends, and API apps in Azure App Service. Azure Application Insights instruments your app to send telemetry about its activities to the Application Insights service, where it is stored and analyzed. There, metric charts and search tools can be used to help diagnose issues, improve performance, and assess usage.
Run time or build time
You can configure monitoring by instrumenting the app in either of two ways:
- Run-time - You can select a performance monitoring extension when your app service is already live. It isn't necessary to rebuild or reinstall your app. You get a standard set of packages that monitor response times, success rates, exceptions, dependencies, and so on.
- Build time - You can install a package in your app in development. This option is more versatile. In addition to the same standard packages, you can write code to customize the telemetry or to send your own telemetry. You can log specific activities or record events according to the semantics of your app domain.
Run time instrumentation with Application Insights
If you're already running an app service in Azure, you already get some monitoring: request and error rates. Add Application Insights to get more, such as response times, monitoring calls to dependencies, smart detection, and the powerful Kusto query language.
Select Application Insights in the Azure control panel for your app service.
Choose to create a new resource, unless you already set up an Application Insights resource for this application.
When you click OK to create the new resource you will be prompted to Apply monitoring settings. Selecting Continue will link your new Application Insights resource to your app service, doing so will also trigger a restart of your app service.
After specifying which resource to use, you can choose how you want application insights to collect data per platform for your application.(ASP.NET app monitoring is on-by-default with two different levels of collection.)
.NET Basic collection level offers essential single-instance APM capabilities.
.NET Recommended collection level:
- Adds CPU, memory, and I/O usage trends.
- Correlates micro-services across request/dependency boundaries.
- Collects usage trends, and enables correlation from availability results to transactions.
- Collects exceptions unhandled by the host process.
- Improves APM metrics accuracy under load, when sampling is used.
.NET Core offers Recommended collection or Disabled for .NET Core 2.0 and 2.1.
Instrument your app service after Application Insights has been installed.
Enable client-side monitoring for page view and user telemetry.
- Select Settings > Application Settings
Under App Settings, add a new key value pair:
- Save the settings and Restart your app.
Explore your app's monitoring data by selecting Settings > Application Insights > View more in Application Insights.
Later, you can build the app with Application Insights if you want.
How do I remove Application Insights, or switch to sending to another resource?
- In Azure, open the web app control blade, and under Settings, open Application Insights. You can turn off Application Insights by clicking Disable at the top, or select a new resource in the Change your resource section.
Build the app with Application Insights
Application Insights can provide more detailed telemetry by installing an SDK into your app. In particular, you can collect trace logs, write custom telemetry, and get more detailed exception reports.
In Visual Studio (2013 update 2 or later), configure Application Insights for your project.
Right-click the web project, and select Add > Application Insights or Project > Application Insights > Configure Application Insights.
If you're asked to sign in, use the credentials for your Azure account.
The operation has two effects:
- Creates an Application Insights resource in Azure, where telemetry is stored, analyzed, and displayed.
- Adds the Application Insights NuGet package to your code (if it isn't there already), and configures it to send telemetry to the Azure resource.
- Test the telemetry by running the app in your development machine (F5).
- Publish the app to Azure in the usual way.
How do I switch to sending to a different Application Insights resource?
- In Visual Studio, right-click the project, choose Configure Application Insights, and choose the resource you want. You get the option to create a new resource. Rebuild and redeploy.
- Workaround 2: add sdk via code and remove extension (Profiler and Snapshot debugger won't with this configuration)
We are tracking this issue here
For .NET Core the following are currently not supported:
- Self-contained deployment.
- Apps targeting the .NET Framework.
- .NET Core 2.2 applications.
.NET Core 2.0 and .NET Core 2.1 are supported. When .NET Core 2.2 support is added this article will be updated.
- Run the profiler on your live app.
- Azure Functions - monitor Azure Functions with Application Insights
- Enable Azure diagnostics to be sent to Application Insights.
- Monitor service health metrics to make sure your service is available and responsive.
- Receive alert notifications whenever operational events happen or metrics cross a threshold.
- Set up Availability web tests to be alerted if your site is down.
We'd love to hear your thoughts. Choose the type you'd like to provide:
Our feedback system is built on GitHub Issues. Read more on our blog.