Skip to content

Connection string env variable does not take precedence over file defined connectionString #4214

Open
@HonzaV

Description

@HonzaV

Expected behavior

I have env variable APPLICATIONINSIGHITS_CONNECTION_STRING and applicationinsights.json file. When I define connection string in configuration file via file path variable, the env variable does not take the precedence.
When I use connectionString hardcoded in configuration file it works well and I would expect the same from the file path variable.

Actual behavior

The startup will fail, because the sdk attempts to read the file which does not exists instead of using the env variable.

To Reproduce

use runtime-attach dependency in pom.xml
<dependency> <groupId>com.microsoft.azure</groupId> <artifactId>applicationinsights-runtime-attach</artifactId> <version>3.7.2</version> </dependency>

configure env variable APPLICATIONINSIGHITS_CONNECTION_STRING with connection string to Application Insights

Define applicationinsights.json configuration file in your application directory with connection string defined as filepath variable

{
  "connectionString": "${file:/app/secrets/applicationinsights_connection_string}"
}

System information

Please provide the following information:

  • SDK Version: 3.7.1
  • OS type and version: Win10, Java 17
  • Application Server type and version (if applicable): Springboots tomcat
  • Using spring-boot? Yes - 3.2.3
  • Additional relevant libraries (with version, if applicable): No

Logs

appins.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions