Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Relic Solution: Installing & Troubleshooting .NET on Azure

level-up
relic-solutions

#1

Azure App Services & the .NET Agent

Azure App Services is Microsoft’s cloud computing service which can be very useful when it comes to building, testing, and hosting your web app, and with New Relic’s .NET agent installed on your instance, you’ll have access to a wealth of performance and diagnostic data.

But how do you install the agent? This tutorial is designed to walk you through the process of getting the agent up and running and reporting data, whether your app targets the traditional .NET Framework or the newer .NET Core (and, as of version 8.1, ASP.NET Core apps running on .NET Framework.)

Initially, to minimize any complications, I recommend disabling Always On, found in the Azure portal under application settings. If you need this to be on later, there are a few workarounds described here.

Kudu: Behind the scenes

Let’s start out by getting familiar with Kudu, which is handy for checking out what’s happening behind the scenes of your app instance. Kudu is a site that runs in parallel with your website and provides various tools that can be used to examine processes, look at the file system, and download files and directories.

If your website’s URL is example.azurewebsites.net then the Kudu site is example.scm.azurewebsites.net. Use your site’s deployment credentials to log into the Kudu site.

Now that you know how to access Kudu (we’ll come back to this later), let’s first try installing the agent. I’ll be starting with the Framework agent, but you can skip ahead to Core below if you’d like.

.NET Framework Installation via App Extensions

Typically, the easiest way to install the .NET agent is by using our New Relic Azure extension. This is found within the Azure Portal, in the sidebar on the left. Scroll down to Extensions:

Now click the icon, select the New Relic extension, approve the legalese, and select OK. (The extension should automatically detect whether your app is 32-bit or 64-bit and install the correct agent.)

Now we just need to add our app settings keys, also found in the Azure Portal’s sidebar. This time, select Application Settings:

We can now add the following key/pair values:

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

Then, restart your app, generate traffic on the app, and hopefully you’ll start seeing data. If not, keep reading!

You can also install the extension via Kudu by going to Site extensions > Gallery, installing the extension, and adding the same keys as above.

.NET Framework NuGet Installation

If you’d prefer to use NuGet and deploy the agent with your application, you’ll need to know whether your Azure instance is 32-bit or 64-bit. To confirm this, you can check the Environment tab of your Kudu app:

Look for 64-bit system. Depending on the value there, run the appropriate command from the Package manager console:

32-bit: Install-Package NewRelic.Azure.WebSites
64-bit: Install-Package NewRelic.Azure.WebSites.x64

You’ll still need to enter the same app settings as above.

If you are using this method, I recommend confirming that all files made it to the newrelic folder located at D:\Home\site\wwwroot\newrelic

Special step for ASP.NET Core apps running on .NET Framework

For these types of apps (which are built with .NET Core but target the .NET Framework), you’ll need the Framework agent 8.1 or above. The agent won’t pick up the name in appSettings.json at this time. I recommend either naming the application in the newrelic.config file or using the NEW_RELIC_APP_NAME key in your Azure app’s settings.

You may also need to specify the name of the targeted .NET Core process in your newrelic.config file.

For example, in this image captured from Kudu’s process explorer tab, here’s the name of my .NET Core process:

//nr-production-discourse.s3.amazonaws.com/original/2X/a/afb933b9b97b9785639dc60a299771a089439f17.png

In this case, I’ll need to add the following to the newrelic.config file:

<instrumentation>
    <applications>
      <application name="coreframework.exe" />
    </applications>
</instrumentation>

.NET Framework agent troubleshooting

Now that you’ve followed the installation instructions, let’s look for New Relic logs. Log into your Kudu app and select Debug Console and Powershell:

Navigate to the following location:

D:\home\LogFiles\NewRelic> 

If you see current logs there, that’s a good sign!

If not, there are a few things we can check:

  • Are there any other .NET profilers running on the system? Double-check the Extensions tab for other profilers that could interfere with New Relic, and delete them if possible.

  • Is Always On disabled or are you using one of the workarounds?

  • Does your app need the 32-bit (x86) or 64-bit (x64) version of the agent? (Remember, you can verify the bitness in Kudu on the Environment tab.)

  • Is Microsoft’s profiler, Application Insights, running in your app? This can interfere with New Relic’s ability to profile your apps.

How to Remove your Application Insights key:

  • Remove the Application Insights Key from Application > Settings > Application Settings and Save.
  • Remove the extension from Application > Tools > Extensions. Right-click the extension and Delete.
  • Remove the Tile Add-On from your Application Panel (if present).
  • Restart your application.

.NET Core Agent Installation

At this time, the Core agent can only be installed by manually copying the agent files over to your instance and pointing the app environment variables (located in your instance’s Application Settings) to where the files “live.”

First, determining what agent bitness to download and copy over will be necessary to get the agent up and running.

Only the 32-bit version of .NET Core 2.0 is pre-installed on your Azure instance, so unless your app is self-contained or deployed with its own 64-bit runtime, you’ll likely want to use the 32-bit (x86) version of the agent. If you did not take extra steps to include an x64 RuntimeIdentifier you’ll likely want the 32-bit version with Azure.

If your app is deployed with its own 64-bit runtime, it 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 that looks like this…

		<PropertyGroup>
		    <TargetFramework>netcoreapp2.0</TargetFramework>
		    <RuntimeIdentifier>win81-x64</RuntimeIdentifier>
		</PropertyGroup>

…probably needs the x64 version of the agent.

PROTIP: Unless you followed one of the extra deployment steps documented in this Microsoft article, you should go with x86.

Once you’ve figured out the correct bitness of the agent you’ll need, you can download it here, use the Debug Console in Kudu to create a newrelic directory in the root of your web site, and extract the files to that location.

You’ll still need to add the following environment variables to the Application Settings in the Azure Portal:

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

One more thing — you’ll also want to navigate to the newrelic.config file and use Kudu to change the <log> element to the following:

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

Then restart your app, generate traffic, and look for it in New Relic!

What about logs?

Log messages can provide clues if you’re not seeing data reporting.

You can access the logs by using Kudu’s debug console to navigate to:

D:\Home\LogFiles\NewRelic

For example, you might see a message like:

Incorrect agent product

This means that either the app settings are set up for monitoring a Framework or Core app, but the incorrect agent is installed.

Process Explorer

If you’re not sure if everything’s set up right, you can confirm this with Kudu’s Process Explorer tab.

Click the Kudu Process Explorer tab, then click the Properties button for the w3wp process.

If there are two w3wp processes, be sure to check the one that doesn’t say SCM, which is a Kudu process.

.NET Framework process example:

.NET Core process example:

Click the Modules tab and look for NewRelic DLL files.

Do you see for example, NewRelic.Profiler.dll? That means the agent is attached to the process. If there are any issues, checking the logs could provide further insight.

Further assistance

If you’re still having trouble with the New Relic agent monitoring your Azure app, feel free to reply here with more details or create a new post! We’re always happy to help.


New Relic Nuget Package for .NET Standard