You can configure New Relic monitoring for Azure Function Apps hosted on Linux. This is achieved by instrumenting your Function App with the appropriate New Relic agent for its runtime such as Node.js, .NET, or Python. This instrumentation allows you to monitor the performance and health of your Azure Functions in real-time within New Relic.
Prerequisites
- Ensure your Azure Function meets our compatibility and requirements.
- Link your Azure account to New Relic. For more information, refer to Azure integration.
Configure Azure Functions monitoring
You can configure Azure Functions monitoring for different environments and various combinations of runtimes and deployment methods:
In the root directory of your Node.js Azure Function App project, install the New Relic agent as a project dependency by running:
npm i newrelicTo ensure that the New Relic agent is installed with your project dependencies during the Azure deployment process, set the
SCM_DO_BUILD_DURING_DEPLOYMENT
totrue
in your application settings by running:az functionapp config appsettings set --name {NAME_OF_YOUR_AZURE_FUNCTION_APP} --settings SCM_DO_BUILD_DURING_DEPLOYMENT=truePublish your Azure Function App using the Azure CLI or your preferred publishing method. You can use one of the following commands to publish your Azure Function App:
func azure functionapp publish {NAME_OF_YOUR_AZURE_FUNCTION_APP}OR
az functionapp app upOR
az functionapp deploy중요
The commands shown here are examples and may require additional parameters based on your specific Azure configuration and deployment strategy such as
OS
,Node.js version
,Azure resource group
,Azure subscription
,Azure storage account
,Azure region
, and so on. Refer to Azure documentation to know more about these parameters forfunc azure functionapp publish
,az functionapp up
, andaz functionapp deploy
methods.
In the root directory of your Python Azure Function App project, open the
requirements.txt
file.Add the following line to your
requirements.txt
file to install the New Relic agent for Azure Function instrumentation:bash$newrelicInitialize and register the New Relic agent in your Azure Function code using one of the following methods:
Publish your Azure Function App using the Azure CLI or your preferred publishing method. You can use the following command to publish your Azure Function App:
bash$func azure functionapp publish ${NAME_OF_YOUR_AZURE_FUNCTION_APP}
Add the latest version of the
NewRelic.Agent
NuGet package to your application project.Use your preferred publishing mechanism to deploy your updated application to Azure.
When you deploy your application, the .NET agent is installed in the
/home/site/wwwroot/newrelic
folder.
Configure environment variables
After you've published the Azure Function app, configure environment variables:
- Navigate to your Azure Function in the Azure portal.
- Under Settings, click Environment variables, and then click Advanced edit.
- Based on your deployment runtime, paste the following values:
중요
Ensure that you add a comma at the end of the last existing line and update your license key in the following configurations.
{ "NODE_OPTIONS": "-r newrelic", "NEW_RELIC_LICENSE_KEY": "YOUR-NEW-RELIC-INGEST-LICENSE-KEY", "NEW_RELIC_APP_NAME": "NAME-OF-THE-FUNCTION-APP"}
{ "NEW_RELIC_LICENSE_KEY": "YOUR-NEW-RELIC-LICENSE-KEY", "NEW_RELIC_APP_NAME": "NAME-OF-THE-FUNCTION-APP", "PYTHONPATH": "${PYTHONPATH}:/home/site/wwwroot:/home/site/wwwroot/.python_packages/lib/site-packages", "FUNCTIONS_WORKER_RUNTIME": "python", "PYTHON_ENABLE_WORKER_EXTENSIONS": 1}
({ "name": "CORECLR_ENABLE_PROFILING", "value": "1", "slotSetting": false},{ "name": "CORECLR_NEW_RELIC_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_LOG_DIRECTORY", "value": "/home/LogFiles/NewRelic", "slotSetting": false},{ "name": "NEW_RELIC_LICENSE_KEY", "value": "<your New Relic ingest license key here>", "slotSetting": false})
Restart your Azure Function
After you've added the environment variables, restart your Azure Function to apply the changes.
Find and use data
After you have configured your Azure Function, you can find and use the data in the New Relic UI.
- Go to https://one.newrelic.com > APM & Services.
- In the search banner, set the search criteria as
isAzureFunction = true
: - From the displayed list, select your Azure Function to view the data.