Install .NET agent on Azure Service Fabric

This document explains how to install New Relic APM's .NET Framework agent and .NET Core agent on Azure Service Fabric. This is not the same as installing the Infrastructure integrations for Microsoft Azure.

Install .NET agent on Azure Service Fabric

In most cases, installing the .NET agent in an Azure Service Fabric environment can be performed using the standard install procedures for either Windows or Linux. This document highlights some alternate ways you can install the agent.

You will need to ensure the agent gets installed on all nodes in your cluster. To monitor multiple nodes, you may want to integrate the install into your deployment process.

If you are using containers in your Service Fabric environment you should read Install for Docker.

You can also install the agent in a Service Fabric environment using NuGet. NuGet is often a good option for developers because the agent gets deployed along with your application. Though, using NuGet requires some manual installation procedures. See Install with NuGet.

Install using NuGet

To install the .NET agent using NuGet:

  1. Follow the standard NuGet install procedures.
  2. When using NuGet, you must set some environment variables. This can be done in your application's ServiceManifest.xml file. See the relevant instructions below:

    .NET Framework

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

    <CodePackage Name="Code" Version="1.0.0">  </CodePackage>
    <CodePackage>
      ...
      <EntryPoint>
        <ExeHost>
          ...
          <!-- It is important for the WorkingFolder to be set to CodePackage -->
          <!-- This is because the environment variables set below rely on this being the working folder for the agent to work -->
          <WorkingFolder>CodePackage</WorkingFolder>
          ...
        </ExeHost>
      </EntryPoint>
      ...
      <EnvironmentVariables>
        ...
        <EnvironmentVariable Name="COR_ENABLE_PROFILING" Value="1" />
        <EnvironmentVariable Name="COR_PROFILER" Value="{71DA0A04-7777-4EC6-9643-7D28B46A8A41}" />
        <EnvironmentVariable Name="COR_PROFILER_PATH" Value=".\newrelic\NewRelic.Profiler.dll" />
        <EnvironmentVariable Name="NEWRELIC_HOME" Value=".\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

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

    <CodePackage>
      ...
      <EntryPoint>
        <ExeHost>
          ...
          <!-- It is important for the WorkingFolder to be set to CodePackage -->
          <!-- This is because the environment variables set below rely on this being the working folder for the agent to work -->
          <WorkingFolder>CodePackage</WorkingFolder>
          ...
        </ExeHost>
      </EntryPoint>
      ...
      <EnvironmentVariables>
        ...
        <EnvironmentVariable Name="CORECLR_ENABLE_PROFILING" Value="1" />
        <EnvironmentVariable Name="CORECLR_PROFILER" Value="{36032161-FFC0-4B61-B559-F6C5D41BAE5A}" />
        <EnvironmentVariable Name="CORECLR_PROFILER_PATH" Value=".\newrelic\NewRelic.Profiler.dll" />
        <EnvironmentVariable Name="CORECLR_NEWRELIC_HOME" Value=".\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

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

    <CodePackage>
      ...
      <EntryPoint>
        <ExeHost>
          ...
          <!-- It is important for the WorkingFolder to be set to CodePackage -->
          <!-- This is because the environment variables set below rely on this being the working folder for the agent to work -->
          <WorkingFolder>CodePackage</WorkingFolder>
          ...
        </ExeHost>
      </EntryPoint>
      ...
      <EnvironmentVariables>
        ...
        <EnvironmentVariable Name="CORECLR_ENABLE_PROFILING" Value="1" />
        <EnvironmentVariable Name="CORECLR_PROFILER" Value="{36032161-FFC0-4B61-B559-F6C5D41BAE5A}" />
        <EnvironmentVariable Name="CORECLR_PROFILER_PATH" Value="./newrelic/libNewRelicProfiler.so" />
        <EnvironmentVariable Name="CORECLR_NEWRELIC_HOME" Value="./newrelic" />
        <EnvironmentVariable Name="NEW_RELIC_LICENSE_KEY" Value="YOUR_LICENSE_KEY" />
        <EnvironmentVariable Name="NEW_RELIC_APP_NAME" Value="YOUR_APP_NAME" />
        ...
      </EnvironmentVariables>
      ...
    </CodePackage>
  3. For the .NET Framework 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: