Hi Devarakonda Amani (SEBT)
T the coupled code tightly caused by the app using a connection string in the spring boot application and applicationisights.attach ()
. To support more scalable and maintainable setups, we recommend using the application Insights Java agent, which enables a complete telemetry collection (request, dependence, log) without the need for any code change. This approach keeps your application relaxed and avoids the requirement of clear SDK calls such as applicationinsights.attach (). For Azure App Service, you can automate this setup:
Deployment of Java Agent (Applicationinsights -Gent.jar) with your application (eg,/home/site/wwwroot/).
Setting the following application settings via azure portal or ARM template: Java_opts = -Javaagent: /home/site/wwwroot/applicationinsights-gent-3.5.0.jar
Applicationinsights_connection_string = <Your connection string>
This configuration ensures dynamic, environment-operated telemetry setup without any tight coupling in your application code. If you prefer a programmatic followback, a reflection-based dynamic attachment method can be used, which handles the absence of application by application and avoids breaking your application. We recommend agent-based setup as it aligns with microsoft best practices, is future proof, and avoids the need for any code-level changes in the atmosphere.
Please accept as "Yes" if the answer provided is useful, so that you can help others in the community looking for remediation for similar issues.
Let me know if you have any further Queries.