• EnglishEspañol日本語한국어Português
  • Log inStart now

Integrate the Python agent on Microsoft Azure Container Apps and App Service

preview

We're still working on this feature, but we'd love for you to try it out!

This feature is currently provided as part of a preview program pursuant to our pre-release policies.

This document provides solutions on New Relic integration into Azure hosted Python applications without having to modify the application code. There are two supported instances of this capability:

Support for New Relic integration for App Services using containerized images is not available.

Compatibility and requirements

Before you begin, we recommend the following:

  • Starting with a Container App or App Service that has been deployed
  • Installing the Azure CLI in your environment if not using the Azure Portal

Info

Keep in mind that the Python agent doesn't capture telemetry for Azure Functions without our integration. We recommend installing the Azure Functions monitoring integration if you'd like to collect data about Azure Functions.

Integrate the Python agent onto Container Apps

In certain cases, an app managed through Azure Container Apps already has an image that cannot be modified by the user (or the user may simply not want to modify the app). This provides a way to integrate New Relic into the environment without having to make any modifications to the code that builds the containerized image.

This can be done through the Azure Portal or the Azure CLI.

Integrate the Python agent onto Azure App Service

Currently App Services only support sidecars but not init containers. Until that support is available, this prebuild script can be used. Note: This only works for App Services using code and not for containerized images.

This can be done through the Azure Portal or the Azure CLI:

bash
$
#!/bin/sh
$
# prebuild.sh
$
$
# Retrieve files to use in startup script:
$
curl -L https://raw.githubusercontent.com/newrelic/newrelic-agent-init-container/refs/heads/main/src/python/newrelic_k8s_operator.py > newrelic_k8s_operator.py
$
curl -L https://raw.githubusercontent.com/newrelic/newrelic-agent-init-container/refs/heads/main/src/python/requirements-vendor.txt > requirements-vendor.txt
$
curl -L https://raw.githubusercontent.com/newrelic/newrelic-agent-init-container/refs/heads/main/src/python/requirements-builder.txt > requirements-builder.txt
$
$
cd /home/
$
$
pip install -r requirements-builder.txt
$
$
export NEW_RELIC_EXTENSIONS=false
$
export WRAPT_DISABLE_EXTENSIONS=true
$
$
pip install newrelic --target=./workspace/newrelic
$
$
mkdir -p ./workspace/vendor
$
pip install --target=./workspace/vendor -r requirements-vendor.txt
$
$
cp ./workspace/* /home/
$
cp /home/workspace/newrelic/newrelic/bootstrap/sitecustomize.py /home/sitecustomize.py
$
$
cd /home/site/wwwroot
$
$
# This is the where the application's original startup script goes:
$
gunicorn app:app

Troubleshooting [#troubleshooting]

In some cases, telemetry may not be available, or that the prebuild.sh script may cause the existing application to fail re-deployment. To remedy this, enable these environment variables:

  • SCM_DO_BUILD_DURING_DEVELOPMENT: True
  • ENABLE_ORYX_BUILD: True
Copyright © 2024 New Relic Inc.

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