diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md b/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md index 2ab49efeb43e..9b5e9fe3ea01 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md @@ -7,6 +7,8 @@ ### Breaking Changes ### Bugs Fixed +- Fix fallback logic when connection string is provided only via environment variable + ([#45252](https://github.com/Azure/azure-sdk-for-python/pull/45252)) ### Other Changes diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_connection_string_parser.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_connection_string_parser.py index 2045a2b66c8e..df22912d6073 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_connection_string_parser.py +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_connection_string_parser.py @@ -50,6 +50,9 @@ def _initialize(self) -> None: env_cs = self._parse_connection_string(os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")) env_ikey = os.getenv("APPINSIGHTS_INSTRUMENTATIONKEY") + if not self._connection_string: + self._connection_string = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING") + # The priority of which value takes on the instrumentation key is: # 1. Key from explicitly passed in connection string # 2. Key from explicitly passed in instrumentation key