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

Esta tradução de máquina é fornecida para sua comodidade.

Caso haja alguma divergência entre a versão em inglês e a traduzida, a versão em inglês prevalece. Acesse esta página para mais informações.

Criar um problema

Instrumentação conteinerizada

Se você estiver usando uma Azure Function em contêiner, pode monitorar suas Azure Functions com o agente .NET, o agente Python ou o agente Node.js do New Relic. Isso permite que você monitore o desempenho e a integridade de suas Azure Functions em tempo real.

Pré-requisitos

Configurar o monitoramento do Azure Functions

Você pode configurar o monitoramento do Azure Functions para diferentes ambientes e várias combinações de tempos de execução e métodos de implantação. As instruções a seguir detalham como configurar o New Relic para Azure Function Apps em contêiner.

  1. Edite seu arquivo de função para adicionar o seguinte código no início do seu arquivo de aplicativo:

    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. Crie sua imagem do Docket de acordo com os requisitos da sua plataforma executando:

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

    Importante

    Certifique-se de substituir YOUR_PLATFORM_ARCHITECTURE pela arquitetura apropriada para sua Azure Function. Por exemplo, use linux/amd64 para Linux de 64 bits ou linux/arm64 para arquitetura ARM.

  3. Publique sua imagem no Azure Container Registry (ACR) executando:

    1. Autentique seu Azure Container Registry:
    bash
    $
    az acr login --name YOUR_CONTAINER_REGISTRY_NAME
    1. Marque sua imagem criada localmente com o servidor de login do ACR executando:
    bash
    $
    docker tag YOUR_DOCKER_ID/azurefunctionsimage:v1.0.0 YOUR_LOGIN_SERVER/azurefunctionsimage:v1.0.0
    1. Envie a imagem marcada para seu ACR executando:
    bash
    $
    docker push YOUR_LOGIN_SERVER/azurefunctionsimage:v1.0.0
    1. Crie os recursos do Azure necessários para seu Azure Function App usando a documentação do Azure..

    2. Crie e configure o Azure Function App usando a imagem que você enviou para o ACR na etapa anterior. Para obter mais informações, consulte a documentação do Azure.

    3. Recupere a URL do Aplicativo de Função do Azure após a implantação executando:

    bash
    $
    az functionapp show --name YOUR_APPLICATION_NAME --resource-group NAME_OF_THE_APPS_RESOURCE_GROUP

Para instalar o agente Python do New Relic, adicione as seguintes linhas ao estágio final do seu 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
RUN pip install newrelic
# Install any other dependencies
COPY requirements.txt /
RUN pip install -r /requirements.txt
COPY . /home/site/wwwroot

Dica

O exemplo acima é para uma Azure Function Python 3.11. Você pode alterar a versão do Python para corresponder aos seus requisitos.

Depois de criar a imagem do Docker, publique a imagem no Registro de Contêiner do Azure. Para obter mais informações, consulte a documentação do Azure.

Para instalar o agente .NET do New Relic, adicione as seguintes linhas ao estágio final do seu arquivo Docker:

# 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/*

Ao implantar seu aplicativo, o agente .NET é instalado na pasta /usr/local/newrelic-dotnet-agent .

Configurar variáveis de ambiente

Depois de publicar o aplicativo Azure Function, configure as variáveis de ambiente:

  1. Navegue até suas Funções Azure no portal Azure .

  2. Em Settings , clique em Environment variables e depois em Advanced edit .

  3. Com base no tempo de execução da sua implantação, cole os seguintes valores:

    Importante

    Certifique-se de adicionar uma vírgula no final da última linha existente e atualize sua chave de licença na seguinte configuração.

    {
    "NODE_OPTIONS": "-r newrelic",
    "NEW_RELIC_LICENSE_KEY": "YOUR_NEW_RELIC_LICENSE_KEY",
    "NEW_RELIC_APP_NAME": "NAME_OF_YOUR_AZURE_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",
    "slotSetting": false
    },
    {
    "name": "NEW_RELIC_LICENSE_KEY",
    "value": "YOUR_NEW_RELIC_LICENSE_KEY",
    "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_LICENSE_KEY",
    "slotSetting": false
    })

Reinicie suas funções Azure

Depois de adicionar as variáveis de ambiente, reinicie o Azure Functions para aplicar as alterações.

Encontre e use dados

Depois de configurar sua Azure Function, você pode localizar e usar os dados na interface New Relic.

  1. Acesse https://one.newrelic.com > APM & Services.

  2. No banner de pesquisa, defina os critérios de pesquisa como isAzureFunction = true:

    A screenshot showing the Azure Function search
  3. Na lista exibida, selecione sua Função do Azure para visualizar os dados.

Compatibilidade e requisitos

Requisitos para suas Azure Functions

Instrumentação Linux

Aprenda a configurar o Azure Functions para Linux para monitorá-lo no New Relic.

Instrumentação Windows

Aprenda a configurar o Azure Functions para Windows para monitorá-lo no New Relic.

Copyright © 2025 New Relic Inc.

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