azure-functions-java-worker
azure-functions-java-worker copied to clipboard
Application insights for Azure Function on Kubernetes
Description of the issue
We're trying to migrate our infrastructure to Kubernetes. That also includes migration of function app. We've manage to do it succesfully, we have a working azure function, however there is a problem with application insights. Namely, it is not working. We don't see any logs not to mention distributed tracing which are vital for us. Is there a way to instrument Java function app insight hosted on kubernetes cluster?
Investigative information
Java version: 11 Here I'm posting a sample configuration from the environment variables of kubernetes deployment:
- name: APPINSIGHTS_INSTRUMENTATIONKEY
valueFrom:
secretKeyRef:
name: external-secrets
key: secret-value
- name: APPLICATIONINSIGHTS_INSTRUMENTATION_SPRING_SCHEDULING_ENABLED
value: "false"
- name: APPLICATIONINSIGHTS_PREVIEW_OTEL_API_SUPPORT
value: "true"
- name: APPLICATIONINSIGHTS_ENABLE_AGENT
value: "true"
- name: XDT_MicrosoftApplicationInsights_Java
value: "1"
- name: ApplicationInsightsAgent_EXTENSION_VERSION
value: ~3
Dockerfile for the image:
FROM mcr.microsoft.com/azure-functions/java:4-java11-core-tools AS installer-env
COPY settings.xml /root/.m2/settings.xml
COPY . /src/java-function-app
RUN cd /src/java-function-app && \
mkdir -p /home/site/wwwroot && \
mvn clean package && \
cd ./target/azure-functions/ && \
cd $(ls -d */|head -n 1) && \
cp -a . /home/site/wwwroot
FROM mcr.microsoft.com/azure-functions/java:4-java11
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"]```