Install the .NET agent on Azure Web Apps

This document explains how to install New Relic APM's .NET Agent for an Azure Web App. This is not the same as installing the Infrastructure integrations for Microsoft Azure.

Before following these instructions, read the .NET agent install overview.

Use any of the following methods to add the New Relic .NET Agent to your Azure-deployed web app. The best option depends on your role, environment, deployments, etc. For example:

Install using the New Relic Azure Site Extension

To install the .NET agent for an Azure Web App using the New Relic Azure Site Extension:

We recommend that you shut down your web application prior to installing the New Relic Azure Site Extension.

  1. Add the site extension: Navigate to http://[yoursitename].scm.azurewebsites.net, then select Site extensions > Gallery.
  2. Select the plus plus icon next to the New Relic site extension.
  3. If you use Azure's Standard or Basic tiers: Ensure that the Always On setting is Off. In the Azure portal, select (your app) > Settings > Configuration > General settings.
  4. In the Azure portal, add New Relic app settings to your Azure App Service.
  5. Restart your web app to use the new version of the agent.

Install using NuGet (.NET Framework)

The NuGet packages in this procedure support only the old packages.config. They do not support the new PackageReference format. For more information, see Microsoft's package reference documentation.

For multi-project solutions, make sure you have selected the correct project (for example, a specific web app project) before installing the NuGet package.

If you are upgrading the .NET Framework agent using NuGet, any changes you made in the newrelic.config will be overwritten. To preserve any changes, save your newrelic.config outside of your project, then restore it after upgrading.

To install the .NET agent on an Azure Web App using NuGet:

  1. In the Azure portal, verify your Azure Platform (32-bit or 64-bit): From the Azure sidebar menu, select App Services > Your Application > Settings > Configuration > General settings.
  2. Open your application in Visual Studio, and install the New Relic NuGet package by running the appropriate command from the Package manager console:
    • 32-bit: Install-Package NewRelic.Azure.WebSites
    • 64-bit: Install-Package NewRelic.Azure.WebSites.x64
  3. Publish your application.
  4. In the Azure portal, open the web app you want to monitor, then select Settings > Configuration.
  5. From Configuration, select + New application setting and add these key/value pairs:

    Key Value
    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
  6. If you use Azure's Standard or Basic tiers: Ensure that the Always On setting is Off. In the Azure portal, select (your app) > Settings > Configuration > General settings.
  7. In the Azure portal, add New Relic app settings to your Azure App Service.
  8. Restart your web app.

Install using NuGet (.NET Core)

New Relic .NET Core agent supports Linux and Windows applications on Azure App Services. The installation process for Azure App Services differs from the .NET Core agent installation procedures for Linux and Windows.

To install the .NET agent on an Azure Web App using NuGet:

  1. Install the NewRelic.Agent NuGet package.
  2. Modify the log node by adding a directory attribute to your newrelic.config file:

    <log directory="D:\Home\LogFiles\NewRelic" level="info"></log>
    
  3. Publish your application.
  4. In the Azure portal, open the web app you want to monitor, then select Settings > Configuration.
  5. From Configuration, select + New application setting and add these key/value pairs:

    Key Value
    CORECLR_ENABLE_PROFILING 1
    CORECLR_PROFILER {36032161-FFC0-4B61-B559-F6C5D41BAE5A}
    CORECLR_PROFILER_PATH_32 D:\Home\site\wwwroot\newrelic\NewRelic.Profiler.x86.dll
    CORECLR_PROFILER_PATH_64 D:\Home\site\wwwroot\newrelic\NewRelic.Profiler.dll
    CORECLR_NEWRELIC_HOME D:\Home\site\wwwroot\newrelic
  6. In the Azure portal, add New Relic app settings to your Azure App Service.
  7. Restart your web app.

Add New Relic app settings to Azure App Services

To add your app settings:

  1. Make sure you have your license key before adding the New Relic .NET agent's app settings.
  2. In the Azure portal, open the web app you want to monitor, then select Configuration > Application settings.
  3. From Application settings, select + New application setting and add these key/value pairs:

    Key Value
    NEW_RELIC_LICENSE_KEY YOUR_LICENSE_KEY
    NEW_RELIC_APP_NAME YOUR_APP_NAME
  4. Save and restart your web app.

Setting the license key and app name with the App settings will override the newrelic.config.

To verify your app's environment variables in your app's Kudu diagnostic console, go to Environment > Environment variables.

For example:

https://myappname.scm.azurewebsites.net/Env.cshtml#envVariables

View your app's performance

Your application must receive traffic in order for you to view its performance in New Relic. You may need to wait a few minutes for data to start appearing. If no data appears, see the troubleshooting procedures for Azure Web Apps.

To view your app's performance in New Relic APM: Go to rpm.newrelic.com > (select an app). The APM Overview page automatically appears. You can also view detailed information about errors, database and instance performance issues, and more.

If you created your New Relic app prior to October 2017, you can use the Azure portal to select the New Relic account blade. You will be automatically logged in with SAML Single Sign-on (SSO) to New Relic APM. You can also view your application's error rate and throughput data in the Azure portal by going to New Relic Accounts > (select your app).

Troubleshooting

If no data appears after installing the agent, generating traffic for your app, and waiting a few minutes, try these troubleshooting tips:

For more help

Recommendations for learning more: