How to use self-provided Application Insights agent instead of the default one in App Services?
I am trying to deploy Java application to the App Services via zip-deployment. I want to provide javaagent of version 3.0-PREVIEW (like in this guide: https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-in-process-agent), but can't succeed. My deployment script looks like that:
az webapp delete \
-n ${APP_NAME} \
-g ${GROUP_NAME} \
--keep-empty-plan \
--keep-metrics
az webapp create \
-n ${APP_NAME} \
-p ${APP_NAME}-sp \
-g ${GROUP_NAME} \
--runtime "JAVA|11-java11" \
|| exit
az webapp log config \
-n ${APP_NAME} \
-g ${GROUP_NAME} \
--docker-container-logging filesystem \
|| exit
az webapp config appsettings set \
-n ${APP_NAME} \
-g ${GROUP_NAME} \
--settings \
COSMOSDB_ENDPOINT=${COSMOSDB_ENDPOINT} \
COSMOSDB_KEY=${COSMOSDB_KEY} \
CLIENT_ID=${CLIENT_ID} \
CLIENT_SECRET=${CLIENT_SECRET} \
TENANT_ID=${TENANT_ID} \
APP_SP_ID=${APP_SP_ID} \
EVENT_HUB_CONNECTION_STRING=${EVENT_HUB_CONNECTION_STRING} \
EVENT_HUB_OFFSET_STORAGE_NAME=${EVENT_HUB_OFFSET_STORAGE_NAME} \
EVENT_HUB_OFFSET_STORAGE_KEY=${EVENT_HUB_OFFSET_STORAGE_KEY} \
APPINSIGHTS_INSTRUMENTATIONKEY=${APPINSIGHTS_INSTRUMENTATIONKEY} \
APPINSIGHTS_PROFILERFEATURE_VERSION=${APPINSIGHTS_PROFILERFEATURE_VERSION} \
APPINSIGHTS_SNAPSHOTFEATURE_VERSION=${APPINSIGHTS_SNAPSHOTFEATURE_VERSION} \
APPLICATIONINSIGHTS_CONNECTION_STRING=${APPLICATIONINSIGHTS_CONNECTION_STRING} \
ApplicationInsightsAgent_EXTENSION_VERSION=${ApplicationInsightsAgent_EXTENSION_VERSION} \
DiagnosticServices_EXTENSION_VERSION=${DiagnosticServices_EXTENSION_VERSION} \
InstrumentationEngine_EXTENSION_VERSION=${InstrumentationEngine_EXTENSION_VERSION} \
SnapshotDebugger_EXTENSION_VERSION=${SnapshotDebugger_EXTENSION_VERSION} \
JAVA_OPTS="${APP_SERVICE_JAVA_OPTS}" \
|| exit
Configurations for AppInsights look like this:
{
"XDT_MicrosoftApplicationInsights_PreemptSdk": "disabled",
"XDT_MicrosoftApplicationInsights_Mode": "recommended",
"XDT_MicrosoftApplicationInsights_BaseExtensions": "disabled",
"SnapshotDebugger_EXTENSION_VERSION": "disabled",
"InstrumentationEngine_EXTENSION_VERSION": "disabled",
"DiagnosticServices_EXTENSION_VERSION": "~3",
"APPINSIGHTS_PROFILERFEATURE_VERSION": "1.0.0",
"APPINSIGHTS_INSTRUMENTATIONKEY": "key",
"APPINSIGHTS_SNAPSHOTFEATURE_VERSION": "1.0.0",
"ApplicationInsightsAgent_EXTENSION_VERSION": "~2"
}
And APP_SERVICE_JAVA_OPTS
equal to -Xms3072m -Xmx3072m -javaagent:/home/site/wwwroot/applicationinsights-agent.jar -Dserver.port=80
which refers to this jar: https://github.com/microsoft/ApplicationInsights-Java/releases/download/3.0.0-PREVIEW.5/applicationinsights-agent-3.0.0-PREVIEW.5.jar
However, looking at the container logs, I see the picture that hardcoded applicationinsgihts-agent-2.5.0.jar is getting picked up anyway and I can't do anything about it.
2020-07-17T20:17:53.475464456Z _____
2020-07-17T20:17:53.475508856Z / _ \ __________ _________ ____
2020-07-17T20:17:53.475518756Z / /_\ \___ / | \_ __ \_/ __ \
2020-07-17T20:17:53.475527056Z / | \/ /| | /| | \/\ ___/
2020-07-17T20:17:53.475535656Z \____|__ /_____ \____/ |__| \___ >
2020-07-17T20:17:53.475543656Z \/ \/ \/
2020-07-17T20:17:53.475551256Z A P P S E R V I C E O N L I N U X
2020-07-17T20:17:53.475558956Z Documentation: http://aka.ms/webapp-linux
2020-07-17T20:17:53.475566456Z
2020-07-17T20:17:53.475573657Z **NOTE**: No files or system changes outside of /home will persist beyond your application's current session. /home is your application's persistent storage and is shared across all the server instances.
2020-07-17T20:17:53.475592957Z
2020-07-17T20:17:53.475600257Z
2020-07-17T20:17:53.475607557Z Setup openrc ...
2020-07-17T20:17:53.791169880Z * Caching service dependencies ... [ ok ]
2020-07-17T20:17:53.806746060Z Updating /etc/ssh/sshd_config to use PORT 2222
2020-07-17T20:17:53.808882971Z Starting ssh service...
2020-07-17T20:17:55.641253905Z ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519
2020-07-17T20:17:56.998956595Z * Starting sshd ... [ ok ]
2020-07-17T20:17:57.013036368Z Skipping AzMon configuration
2020-07-17T20:17:57.013606371Z Add public certificates to keystore if exists...
2020-07-17T20:17:57.013627671Z Add private certificates to keystore if exists...
2020-07-17T20:17:57.014490775Z Initializing App Insights applicationinsights-agent-codeless-2.5.0.jar....
2020-07-17T20:17:57.032073866Z STARTUP_FILE=
2020-07-17T20:17:57.032428868Z STARTUP_COMMAND=
2020-07-17T20:17:57.032445568Z No STARTUP_FILE available.
2020-07-17T20:17:57.032454668Z No STARTUP_COMMAND defined.
2020-07-17T20:17:58.291968653Z Made a local copy of the app and using APP_JAR_PATH=/local/site/wwwroot/app.jar
2020-07-17T20:17:58.292612556Z Running command: java -noverify -Xms3072m -Xmx3072m -javaagent:/home/site/wwwroot/applicationinsights-agent.jar -Dserver.port=80 -jar /local/site/wwwroot/app.jar
2020-07-17T20:17:58.292973258Z Launched child process with pid: 123
2020-07-17T20:17:58.293347360Z Waiting for main process to exit. global_pid_main=123
2020-07-17T20:17:58.293457160Z Waiting for global_pid_main == 123
2020-07-17T20:17:58.314055766Z Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/local/app_insights/applicationinsights-agent-codeless-2.5.0.jar -Djava.net.preferIPv4Stack=true
How do I configure my project to use new App Insights jar with ApplicationInsights.json
config?