• /
  • EnglishEspañolFrançais日本語한국어Português
  • EntrarComeçar agora

Containerized instrumentation

If you are using a containerized Azure Function, you can monitor your Azure Functions with the New Relic .NET agent, Python agent, or Node.js agent. This allows you to monitor the performance and health of your Azure Functions in real-time.

Prerequisites

Configure Azure Functions monitoring

You can configure Azure Functions monitoring for different environments and various combinations of runtimes and deployment methods. The following instructions detail how to configure New Relic for containerized Azure Function Apps.

  1. Edit your Function file to add the following code at the top of your application file:

    ENV NEW_RELIC_LICENSE_KEY=”{YOUR_NEW_RELIC_LICENSE_KEY}”
    ENV NEW_RELIC_APP_NAME=”{YOUR_APPLICATION_NAME}”
    # ENV NEW_RELIC_HOST='staging-collector.newrelic.com'
    # Uncomment the previous line if using staging
    # Inject the agent in NODE_OPTIONS
    ENV NODE_OPTIONS=”-r newrelic”
    # Install New Relic without bin links
    ARG AGENT_VERSION=latest
    RUN npm install newrelic@${AGENT_VERSION} --no-bin-links
  2. Build your Docket image as per your platform requirements by running:

    docker buildx build --platform={YOUR_PLATFORM_ARCHITECTURE} --tag {YOUR_DOCKER_ID}/azurefunctionsimage:v1.0.0 --push

    Importante

    Ensure that you replace {YOUR_PLATFORM_ARCHITECTURE} with the appropriate architecture for your Azure Function. For example, use linux/amd64 for 64-bit Linux or linux/arm64 for ARM architecture.

  3. Publish your image to the Azure Container Registry (ACR) by running:

    1. Authenticate your Azure Container Registry:

      az acr login --name <YOUR_CONTAINER_REGISTRY_NAME>
    2. Tag your locally built image with the ACR login server by running:

      docker tag {YOUR_DOCKER_ID}/azurefunctionsimage:v1.0.0 {YOUR_LOGIN_SERVER}/azurefunctionsimage:v1.0.0
    3. Push the tagged image to your ACR by running:

      docker push <YOUR_LOGIN_SERVER>/azurefunctionsimage:v1.0.0
    4. Create the required Azure resources for your Azure Function App using the Azure documentation..

    5. Create and configure the Azure Function App using the image you pushed to the ACR in the previous step. For more information, refer to the Azure documentation.

    6. Retrieve the Azure Function App URL after deployment by running:

      az functionapp show --name <YOUR_APPLICATION_NAME> --resource-group <NAME_OF_THE_APPS_RESOURCE_GROUP>

To install the New Relic Python agent, add the following lines to the final stage of your Dockerfile:

FROM mcr.microsoft.com/azure-functions/python:4-python3.11
# These commands will not be required once the
# New Relic Python Agent releases this feature
RUN apt-get update
RUN apt-get -y install git
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
COPY requirements.txt /
RUN pip install -r /requirements.txt
COPY . /home/site/wwwroot

Dica

The above example is for a Python 3.11 Azure Function. You can change the version of Python to match your requirements.

After your have built the Docker image, publish the image to the Azure Container Registry. For more information, refer to Azure documentation.

To install the New Relic .NET agent, add the following lines to the final stage of your Docker file:

# Install the latest New Relic .NET agent using the apt-get package manager
# To install a specific version of the .NET agent, add the version number to the apt-get install line (i.e. apt-get install -y newrelic-dotnet-agent=10.38.0)
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/*

When you deploy your application, the .NET agent is installed in the /usr/local/newrelic-dotnet-agent folder.

Configure environment variables

After you've published the Azure Function app, configure environment variables:

  1. Navigate to your Azure Function in the Azure portal.
  2. Under Settings, click Environment variables, and then click Advanced edit.
  3. Based on your deployment runtime, paste the following values:

Importante

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"
}
({
"name": "PYTHON_ENABLE_WORKER_EXTENSIONS",
"value": "1",
"slotSetting": false
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "python",
"slotSetting": false
},
{
"name": "PYTHONPATH",
"value": "${PYTHONPATH}:/home/site/wwwroot:/home/site/wwwroot/.python_packages/lib/site-packages",
"slotSetting": false
},
{
"name": "NEW_RELIC_APP_NAME",
"value": "<your New Relic app name here>",
"slotSetting": false
},
{
"name": "NEW_RELIC_LICENSE_KEY",
"value": "<your New RElic ingest license key here>",
"slotSetting": false
})
({
"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.

  1. Go to https://one.newrelic.com > APM & Services.
  2. In the search banner, set the search criteria as isAzureFunction = true: A screenshot showing the Azure Function search
  3. From the displayed list, select your Azure Function to view the data.

Compatibility and requirements

Requirements for your Azure Functions

Linux instrumentation

Learn how to set up your Azure Functions for Linux to monitor them in New Relic.

Windows instrumentation

Learn how to set up your Azure Functions for Windows to monitor them in New Relic.

Copyright © 2025 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.