How to configure New Relic for Azure Web Apps?
New Relic monitoring for Azure Web Apps explained through site extensions, NuGet installation, agent configuration, app settings, Apdex and alert verification.
How to configure New Relic for Azure Web Apps?
We can’t imagine running hassle free operation of modern applications without an Application Performance Monitoring (APM) tool. In the previous article, we discussed how to set up Azure Application Insights for an ASP.NET application. Application Insights is a good choice when everything is on Azure and on .NET, but many organizations already have a different APM tool across their landscape, and New Relic is one of the most popular ones. In our case, some of our applications are already monitored with New Relic and the operations team wanted one tool and one set of dashboards for all applications, regardless of where they are hosted.
In this article, we are going to see what is New Relic APM, how it works with Azure Web Apps, and the step by step instructions to configure the New Relic .NET agent for an ASP.NET application hosted in Azure App Service.
We can install the New Relic agent on an Azure Web App in two ways:
| Approach | Pros | Cons |
|---|---|---|
| Site extension from the Azure portal | + No code change<br>+ Quick to try | − Agent version is managed outside the source code<br>− Manual step per Web App |
| NuGet package in the project | + Agent version is in source control<br>+ Same setup for every deployment and every slot | − Needs a code change and a deployment<br>− Agent files are part of the package |
In our case, we use the NuGet package approach, because the agent is deployed with the application through VSTS Release Management and every environment gets the same version.
TL;DR Summary
- New Relic APM monitors response time, throughput, error rate, Apdex and transaction traces of our applications.
- The .NET agent is a CLR profiler which instruments the application at runtime, no code change is needed for the basic metrics.
- On Azure Web Apps, the agent is installed through a site extension or the
NewRelic.Azure.WebSitesNuGet package. - The profiler is enabled with app settings,
COR_ENABLE_PROFILING,COR_PROFILERand the license key. - Use a different application name per environment, otherwise QA and Production data is mixed.
- Configure Apdex T and alert policies based on your SLA.
Challenges
One tool per platform
When the applications on-premises are monitored with one tool and the applications on Azure with another, the operations team has two consoles, two alerting systems and no single view of the end-to-end transaction.
Restricted environment
Azure Web Apps is a Platform as a Service (PaaS). We cannot log into the server and run an installer like we do on a VM. The agent must be installed in a way which works within the sandbox of App Service.
Agent across slots and scale out
When the Web App scales out to more instances or when we swap deployment slots, the monitoring must continue without manual steps.
What is New Relic APM?
New Relic APM is a Software as a Service (SaaS) application performance monitoring product which collects performance data from language specific agents running inside our applications and presents it in real time dashboards, transaction traces, error analytics and alerts.
In simple terms, New Relic places a small agent inside our application, the agent watches every request and sends the summary to New Relic’s cloud, where we see how fast, how busy and how healthy our application is.
The following diagram depicts how New Relic works with an Azure Web App.

The .NET agent runs as a CLR profiler inside the Web App’s worker process. It instruments the ASP.NET pipeline, database calls and external HTTP calls, and sends the metrics and traces over HTTPS to the New Relic collector. The developers and operations team use the New Relic dashboards and receive the alerts.
Why New Relic is important for us?
In order to have one APM tool and one set of dashboards and alerts across all our applications, to remove the blind spots in our Azure hosted applications and to take proactive actions before the issues are impacting our customers, we decided to configure New Relic for our Azure Web Apps as well. Its transaction traces and database query analysis were also very helpful in our past investigations, for example to validate the effect of a change on the origin servers.
Steps to Implement:
Follow the following instructions to configure New Relic for an ASP.NET application on Azure Web Apps.
Get the license key
- Login to your New Relic account (or create one, New Relic is also available through the Azure Marketplace).
- Open “Account settings” and copy the license key.
Install the agent
-
In Visual Studio, install the New Relic NuGet package for Azure Web Apps in the web project.
Install-Package NewRelic.Azure.WebSitesNote: Use the
NewRelic.Azure.WebSites.x64package if your Web App runs in 64-bit mode. The platform setting is in the Web App “Application settings” blade. -
The package adds a
newrelicfolder to the project with the profiler and thenewrelic.configfile. Make sure these files are included in the publish output. -
Open
newrelic.configand set the application name. Prefer to set it from app settings per environment (next step), so the same package can be deployed to all environments.
Configure the app settings
-
Login to the Azure portal and open the Web App → “Application settings”.
-
Add the following app settings. Replace the input place holders with actual values.
COR_ENABLE_PROFILING = 1 COR_PROFILER = {71DA0A04-7777-4EC6-9643-7D28B46A8A41} COR_PROFILER_PATH = D:\Home\site\wwwroot\newrelic\NewRelic.Profiler.dll NEWRELIC_HOME = D:\Home\site\wwwroot\newrelic NEWRELIC_LICENSEKEY = <license key> NEW_RELIC_APP_NAME = <application name>-<environment>Info: The exact setting names and paths can change between agent versions. Always check the New Relic documentation for the agent version you install
[confirm: values against the agent version used]. -
Mark the license key setting as a “Slot setting” when you use deployment slots, so each slot keeps its own configuration after a swap.
-
Save the settings and restart the Web App. The profiler is loaded only when the worker process starts.
Pulse check
- Just to pulse check, browse few pages of the application to generate traffic.
- Open New Relic → APM. The application should appear with the name you configured within few minutes.
- If it doesn’t appear, open the Kudu console (
https://<web app name>.scm.azurewebsites.net) and check the agent logs inD:\Home\site\wwwroot\newrelic\logs.
Configure Apdex and alerts
- Open the application → “Settings” → “Application” and set the Apdex T value based on the expected response time of your application (ex: 0.5 seconds for an API).
- Create an alert policy with conditions for Apdex, error rate and response time, and notification channels like email, Slack or PagerDuty.
- Enable “Transaction traces” and set the threshold, so slow requests are captured with full detail.
Things to keep in mind
- The agent adds a small overhead to every request. It is usually very small, but measure it in a load test before enabling it on very high throughput APIs.
- Application names are how New Relic groups the data. Use a naming convention like
<application>-<environment>across all teams. - Running both Application Insights and New Relic profilers in the same Web App is not recommended, two CLR profilers can conflict.
- Browser monitoring needs the JavaScript snippet in the layout page, either through automatic injection or by adding it manually.
Must Do and Don’ts
- Must Do: Use a different application name per environment.
- Must Do: Keep the license key in app settings, not in source control.
- Must Do: Configure alert policies, a dashboard nobody watches is not monitoring.
- Should: Keep the agent version in source control through the NuGet package.
- Don’t: enable two APM profilers in the same process.
- Don’t: set an Apdex T value without understanding your users’ expectations, otherwise the score is meaningless.
Wrap up
In this article, we have looked at the two ways to install New Relic on Azure Web Apps, what is New Relic APM, how the agent works and the step by step instructions to install the agent, configure the app settings, verify it and set up Apdex and alerts. Thanks for reading this article. In the next article, I will walk you through how to use Azure DocumentDB from .NET.
Related Posts
How to set up Azure Application Insights for an ASP.NET application?
Azure Application Insights explained through server and browser telemetry, custom events, dependencies, alerts, availability tests and ASP.NET application monitoring.
Getting started with Docker - Part 1
Getting started with Docker through images, containers, Docker Toolbox, Docker Machine, host addresses, and basic Docker 1.x commands for practical first steps.
How to document ASP.NET Web API with Swagger?
Documenting ASP.NET Web API 2 with Swagger and Swashbuckle, XML comments, response contracts, and Swagger UI for an explicit API contract.