'Azure Python container and how to pass in New Relic app name

So I have a docker container with a python app and new relic python agent. In azure devops, I push the container to my registry, and then release it to a web app container. The newrelic.ini file within the container contains the new relic app name, which I set to a dummy name for now. When deployed, that app is reporting to new relic under the dummy name, so I know that new relic is reporting correctly from the container. What I need to do now is to alter the app name depending on which web app I am deploying the container to. So in the dockerfile I have :

FROM python:3.8-slim-buster
WORKDIR /app
COPY requirements.txt requirements.txt
RUN pip3 install --upgrade pip
RUN pip3 install -r requirements.txt
ARG NEW_RELIC_APP_NAME
ENV NEW_RELIC_APP_NAME $NEWRELICAPPNAME

COPY . .
CMD ["python3", "app.py"]

Then in the release I am specifying the app setting :

steps:
- task: AzureRmWebAppDeployment@4
  displayName: 'Deploy Container'
  inputs:
    azureSubscription: 'Subscription ID'
    appType: webAppContainer
    WebAppName: 'MYAPPNAME'
    DockerNamespace: myregistry.azurecr.io
    DockerRepository: 'myappcontainer:latest'
    ConfigurationSettings: '-NEW_RELIC_APP_NAME MYAPPNAME'

And I can see this app setting in https://myapp.scm.azurewebsites.net/env in the environment variables section and the App settings section :

APPSETTING_NEW_RELIC_APP_NAME = MYAPPNAME
NEW_RELIC_APP_NAME = MYAPPNAME

I have tried restarting, scaling, redeploying. It just reports as the name set within the newrelic.ini file. Has anyone transformed the value to change where new relic reports when deploying the same container to different environments? What am I missing?

Thanks!



Solution 1:[1]

The New Relic documentation regarding environment variables: https://docs.newrelic.com/docs/apm/agents/python-agent/configuration/python-agent-configuration/#agent-configuration-file

Environment variables allow you to override the defaults for certain core settings. If the equivalent setting is explicitly listed in the agent config file, the config file settings take precedence over the environment variable.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ChuckCottrill