Install the .NET agent on Azure Web Apps

This document explains how to install the New Relic .NET agent (Framework and Core) for Azure Web Apps.

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

Install .NET Framework agent

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

  • For developer teams, best practice may be to use NuGet.
  • For operations teams that need to monitor the app, best practice may be to use the extension.

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.

Manual installation using NuGet

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.

To manually install the .NET agent for Azure Web Apps:

  1. Verify your Azure Platform (32-bit or 64-bit): From the Azure sidebar menu, select App Services > Your Application > Settings > Application 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. Add App settings to your Azure web app.
  5. 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 > Application Settings.
  6. Restart your web app.
Extension installation using the SCM website

To manually install the .NET agent for Azure web apps using the New Relic Site extension for your New Relic account:

  1. Add App settings to your Azure Web App.
  2. Add the site extension: Navigate to http://[yoursitename].scm.azurewebsites.net, then select Site extensions > Gallery.
  3. Next to the New Relic site extension, select the plus plus icon.
  4. 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 > Application Settings.
  5. Restart your web app.

Add New Relic settings to Azure Web Apps (.NET Framework)

To add your app settings:

  1. Make sure you have your license key before adding the New Relic .NET agent's app settings.
  2. Open the web app you want to monitor, then select Settings > Application settings.
  3. From App settings, 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
    NEW_RELIC_LICENSE_KEY YOUR_LICENSE_KEY
  4. Save and restart your web app.

Install New Relic .NET Core agent

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 Core agent on Azure App Services:

  1. Choose an application package based on how your application is published. For more information about configuring your application to use the 64-bit version of .NET Core in Azure, review Microsoft's documentation on 64-bit ASP.NET Core on Azure App Service.

    Apps that are not self-contained

    These applications must use the x86 package of the agent. This is because apps published to Azure App Services that are not self-contained utilize the x86 version of .NET Core that is pre-installed. This is true regardless of the server architecture you choose.

    Self-contained apps or apps deployed with their own 64-bit runtime

    These applications must use the x64 package of the agent. This is because apps published to Azure App Services with an x64 RuntimeIdentifier for self-contained publish run as x64 applications.

    Example: Configuration inside a .csproj file may look like this:

    		<PropertyGroup>
    		    <TargetFramework>netcoreapp2.0</TargetFramework>
    		    <RuntimeIdentifier>win81-x64</RuntimeIdentifier>
    		</PropertyGroup>
  2. Download the .NET Core agent for your service type from the New Relic download site.
  3. Create a newrelic directory in the root of your web site.
  4. Extract the agent to that directory.
  5. Add App settings to your Azure app.

    Environment variables for Azure App Services are set in the Azure UI, in your app's Application settings > App settings page.

    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
  6. Modify the agent log file location in your newrelic.config file:

    <log directory="D:\Home\LogFiles\NewRelic" level="info"></log>

Add New Relic settings to Azure App Services (.NET Core)

To add your app settings:

  1. Make sure you have your license key before adding the New Relic .NET agent's app settings.
  2. Open the web app you want to monitor, then select Settings > Application settings.
  3. From App settings, add these key/value pairs:

    Key Value
    CORECLR_ENABLE_PROFILING 1
    CORECLR_PROFILER {36032161-FFC0-4B61-B559-F6C5D41BAE5A}
    CORECLR_PROFILER_PATH D:\Home\site\wwwroot\newrelic\NewRelic.Profiler.dll
    CORECLR_NEWRELIC_HOME D:\Home\site\wwwroot\newrelic
    NEW_RELIC_LICENSE_KEY YOUR_LICENSE_KEY
    NEW_RELIC_APP_NAME YOUR_APP_NAME
  4. Save and restart your web app.

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 steps:

  • Make sure that all files in the newrelic directory at the root of your app got published to Azure.
  • Make sure the environment variables are set correctly.
  • Refer to additional Azure troubleshooting procedures as applicable.

For more help

Recommendations for learning more: