Before you begin
Ensure that your Azure Functions meet our compatibility and requirements.
Link your Azure account to New Relic
You can link your Azure account to New Relic by configuring the polling of Azure monitor metrics. This allows you to see the metrics in the New Relic UI. For more information, refer Azure integration.
Instrument your Azure Functions with the New Relic .NET Agent
Based on your requirement, select one of the following options to instrument your Azure Functions with the New Relic .NET agent.
Add the
NewRelic.Agent
NuGet package to your application project.- In Visual Studio code editor, use NuGet Package Manager to search for and add the latest version of
NewRelic.Agent
to your application. - If you're using other development environments, you can add the package with
dotnet add packages NewRelic.Agent
.
- In Visual Studio code editor, use NuGet Package Manager to search for and add the latest version of
Use your preferred publishing mechanism to deploy your updated application to Azure. This includes the New Relic agent, which is installed to the
/home/site/www/newrelic
folder.
Navigate to Kudu service page and do the following:
- In the Azure portal, navigate to your function app.
- Click the Development tools section, and select Advanced Tools > Go.
- To view the available site extensions, click the Site extensions tab.
- To install the extension, search for
New Relic .NET Agent
and, click +.
To install the New Relic .NET agent, in the final stage of your Dockerfile, add the following lines:
# install the latest New Relic .NET agent using the apt-get package manager RUN apt-get update && apt-get install -y wget ca-certificates gnupg \ && echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list \ && wget https://download.newrelic.com/548C16BF.gpg \ && apt-key add 548C16BF.gpg \ && apt-get update \ && apt-get install -y newrelic-dotnet-agent \ && rm -rf /var/lib/apt/lists/*
Configure the environment variables
After you've instrumented your Azure Functions with the New Relic .NET Agent, do the following to configure the environment variables to send the data to New Relic.
Navigate to your Azure Functions in the Azure portal, under Settings, click Environment variables, and then click Advanced edit.
Based on your application requirement, paste the following values.
Importante
Ensure that you add a comma at the end of the last existing line and update your license key and app name in the following configurations.
{ "name": "CORECLR_ENABLE_PROFILING", "value": "1", "slotSetting": false},{ "name": "CORECLR_NEWRELIC_HOME", "value": "/home/site/wwwroot/newrelic", "slotSetting": false},{ "name": "CORECLR_PROFILER", "value": "{36032161-FFC0-4B61-B559-F6C5D41BAE5A}", "slotSetting": false}, { "name": "CORECLR_PROFILER_PATH", "value": "/home/site/wwwroot/newrelic/libNewRelicProfiler.so", "slotSetting": false},{ "name": "NEW_RELIC_AZURE_FUNCTION_MODE_ENABLED", "value": "1", "slotSetting": false},{ "name": "NEW_RELIC_LICENSE_KEY", "value": "<your newrelic license key here>", "slotSetting": false},{ "name": "NEWRELIC_LOG_DIRECTORY", "value": "/home/LogFiles/NewRelic", "slotSetting": false},{ "name": "NEWRELIC_LOG_LEVEL", "value": "info", "slotSetting": false},
{ "name": "CORECLR_PROFILER_PATH", "value": "C:\\home\\NewRelicAgent\\Core\\NewRelic.Profiler.dll", "slotSetting": false},{ "name": "CORECLR_NEWRELIC_HOME", "value": "C:\\home\\NewRelicAgent\\Core", "slotSetting": false},{ "name": "NEWRELIC_LOG_DIRECTORY", "value": "C:\\home\\LogFiles\\NewRelic", "slotSetting": false},{ "name": "NEW_RELIC_AZURE_FUNCTION_MODE_ENABLED", "value": "1", "slotSetting": false},{ "name": "CORECLR_ENABLE_PROFILING", "value": "1", "slotSetting": false},{ "name": "CORECLR_PROFILER", "value": "{36032161-FFC0-4B61-B559-F6C5D41BAE5A}", "slotSetting": false},{ "name": "NEW_RELIC_LICENSE_KEY", "value": "<your newrelic license key here>", "slotSetting": false},{ "name": "NEWRELIC_LOG_LEVEL","value": "info", "slotSetting": false},{ "name": "NEW_RELIC_APP_NAME", "value": "<your app name>", "slotSetting": false},
{ "name": "CORECLR_ENABLE_PROFILING", "value": "1", "slotSetting": false},{ "name": "CORECLR_NEWRELIC_HOME", "value": "/usr/local/newrelic-dotnet-agent", "slotSetting": false},{ "name": "CORECLR_PROFILER", "value": "{36032161-FFC0-4B61-B559-F6C5D41BAE5A}", "slotSetting": false}, { "name": "CORECLR_PROFILER_PATH", "value": "/usr/local/newrelic-dotnet-agent/libNewRelicProfiler.so", "slotSetting": false},{ "name": "NEW_RELIC_AZURE_FUNCTION_MODE_ENABLED", "value": "1", "slotSetting": false},{ "name": "NEW_RELIC_LICENSE_KEY", "value": "<your newrelic license key here>", "slotSetting": false},{ "name": "NEWRELIC_LOG_DIRECTORY", "value": "/home/LogFiles/NewRelic", "slotSetting": false},{ "name": "NEWRELIC_LOG_LEVEL", "value": "info", "slotSetting": false},
Restart your Azure Functions
After you've added the environment variables, restart your Azure Functions to apply the changes.
What's next
After you complete the installation and configuration steps, send traffic to your Azure Functions to see the metrics in the New Relic UI dashboard.