Install .NET agent on Azure Service Fabric

This document explains how to install the New Relic .NET Framework agent and .NET Core agent on Azure Service Fabric.

Install .NET agent on Azure Service Fabric

Before installing, read these tips and considerations:

  • Read the .NET agent install explanation, which will given you some helpful context for what happens during the install process.
  • If you have an ASP.NET Core application targeting .NET Framework, you must use the .NET Framework agent (not the .NET Core agent).
  • The correct method of install for you will depend on your role, environment, deployments, and perhaps other factors. Some considerations:
    • For developer teams, the best practice may be to use NuGet.
    • For operations teams with control over how the agent is installed, the best options may be:

Install instructions:

.NET Framework agent install

The MSI installer works only for one node. To monitor multiple nodes, you may want to integrate it into your deployment pipeline.

Install procedures:

.NET Core agent install

ASP.NET Core applications that target .NET Framework must use New Relic's .NET Framework agent, not the .NET Core agent.

Install using NuGet

ASP.NET Core applications that target .NET Framework must use New Relic's .NET Framework agent, not the .NET Core agent.

To install the .NET Framework agent or .NET Core agent using NuGet:

  1. Open your Visual Studio solution, or create a new one by selecting File > New > Project. For multi-project solutions, be sure to select the correct project (for example, a specific website project).
  2. Open the Package Manager console by selecting Tools > Library Package Manager > Package Manager Console. Set your project as the default project.
  3. From the Package Manager command prompt, type Install-Package NewRelic.Agent and press Enter. When you build your project, the .NET agent folder will be copied to your build output directory.
  4. Set the environment variables in your application's ServiceManifest.xml file. See the relevant instructions below:

    .NET Framework

    Important: The directory name (APP_DEPLOYMENT_DIRECTORY in the code example below) may not be known until you deploy the application. One solution for this is to deploy your application and then log into the cluster to get the correct directory name.

    In the ServiceManifest.xml file in your project, include the following under the CodePackage node:

    <CodePackage>
      ...
      <EnvironmentVariables>
        ...
        <EnvironmentVariable Name="COR_ENABLE_PROFILING" Value="1" />
        <EnvironmentVariable Name="COR_PROFILER" Value="{71DA0A04-7777-4EC6-9643-7D28B46A8A41}" />
        <EnvironmentVariable Name="COR_PROFILER_PATH" Value="..\APP_DEPLOYMENT_DIRECTORY\newrelic\NewRelic.Profiler.dll" />
        <EnvironmentVariable Name="NEWRELIC_HOME" Value="..\APP_DEPLOYMENT_DIRECTORY\newrelic" />
        <EnvironmentVariable Name="NEW_RELIC_LICENSE_KEY" Value="YOUR_LICENSE_KEY" />
        <EnvironmentVariable Name="NEW_RELIC_APP_NAME" Value="YOUR_APP_NAME" />
        ...
      </EnvironmentVariables>
      ...
    </CodePackage>
    .NET Core for Windows

    Important: The directory name (APP_DEPLOYMENT_DIRECTORY in the code example below) may not be known until you deploy the application. One solution for this is to deploy your application and then log into the cluster to get the correct directory name.

    In the ServiceManifest.xml file in your project, include the following under the CodePackage node:

    <CodePackage>
      ...
      <EnvironmentVariables>
        ...
        <EnvironmentVariable Name="CORECLR_ENABLE_PROFILING" Value="1" />
        <EnvironmentVariable Name="CORECLR_PROFILER" Value="{36032161-FFC0-4B61-B559-F6C5D41BAE5A}" />
        <EnvironmentVariable Name="CORECLR_PROFILER_PATH" Value="..\APP_DEPLOYMENT_DIRECTORY\newrelic\NewRelic.Profiler.dll" />
        <EnvironmentVariable Name="CORECLR_NEWRELIC_HOME" Value="..\APP_DEPLOYMENT_DIRECTORY\newrelic" />
        <EnvironmentVariable Name="NEW_RELIC_LICENSE_KEY" Value="YOUR_LICENSE_KEY" />
        <EnvironmentVariable Name="NEW_RELIC_APP_NAME" Value="YOUR_APP_NAME" />
        ...
      </EnvironmentVariables>
      ...
    </CodePackage>
    .NET Core for Linux

    Important: The directory name (APP_DEPLOYMENT_DIRECTORY in the code example below) may not be known until you deploy the application. One solution for this is to deploy your application and then log into the cluster to get the correct directory name.

    In the ServiceManifest.xml file in your project, include the following under the CodePackage node:

    <CodePackage>
      ...
      <EnvironmentVariables>
        ...
        <EnvironmentVariable Name="CORECLR_ENABLE_PROFILING" Value="1" />
        <EnvironmentVariable Name="CORECLR_PROFILER" Value="{36032161-FFC0-4B61-B559-F6C5D41BAE5A}" />
        <EnvironmentVariable Name="CORECLR_PROFILER_PATH" Value="../APP_DEPLOYMENT_DIRECTORY/newrelic/libNewRelicProfiler.so" />
        <EnvironmentVariable Name="CORECLR_NEWRELIC_HOME" Value="../APP_DEPLOYMENT_DIRECTORY/newrelic" />
        <EnvironmentVariable Name="NEW_RELIC_LICENSE_KEY" Value="YOUR_LICENSE_KEY" />
        <EnvironmentVariable Name="NEW_RELIC_APP_NAME" Value="YOUR_APP_NAME" />
        ...
      </EnvironmentVariables>
      ...
    </CodePackage>
  5. For the .NET Framework agent only: Edit your app.config file and add the NewRelic.AgentEnabled app setting:

    <appSettings>
      ...
      <add key="NewRelic.AgentEnabled" value="true" />
      ...
    </appSettings>

If your application is generating traffic, data should appear in your New Relic APM account in several minutes. If data does not appear, try these troubleshooting steps:

  • Make sure that all files in the newrelic directory at the root of your app was published to Azure.
  • Make sure the environment variables are set correctly.
  • See the general troubleshooting documentation to check for common errors.

For more help

Recommendations for learning more: