From 3c144f7826158dcb396d65a13187e9cf7e2caea3 Mon Sep 17 00:00:00 2001 From: Radhika Gupta Date: Wed, 18 Feb 2026 15:50:33 -0800 Subject: [PATCH 1/6] Fix fallback logic for extracting connection string from env var --- .../azure-monitor-opentelemetry-exporter/CHANGELOG.md | 2 ++ .../azure/monitor/opentelemetry/exporter/export/_base.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md b/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md index 2ab49efeb43e..0300fe2754c7 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 + ([#XXXXX](https://github.com/Azure/azure-sdk-for-python/pull/XXXXX)) ### Other Changes diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py index 759ec19cb6fb..4900759a4aef 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py @@ -120,7 +120,10 @@ def __init__(self, **kwargs: Any) -> None: self._credential = _get_authentication_credential(**kwargs) self._consecutive_redirects = 0 # To prevent circular redirects self._disable_offline_storage = kwargs.get("disable_offline_storage", False) - self._connection_string = parsed_connection_string._connection_string + self._connection_string = ( + parsed_connection_string._connection_string or + os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING", None) + ) self._endpoint = parsed_connection_string.endpoint self._region = parsed_connection_string.region self._instrumentation_key = parsed_connection_string.instrumentation_key From deff277f81897b0f0dd2e0ac41bae6194fb3805b Mon Sep 17 00:00:00 2001 From: Radhika Gupta Date: Wed, 18 Feb 2026 15:52:13 -0800 Subject: [PATCH 2/6] Update CHANGELOG --- sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md b/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md index 0300fe2754c7..9b5e9fe3ea01 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md @@ -8,7 +8,7 @@ ### Bugs Fixed - Fix fallback logic when connection string is provided only via environment variable - ([#XXXXX](https://github.com/Azure/azure-sdk-for-python/pull/XXXXX)) + ([#45252](https://github.com/Azure/azure-sdk-for-python/pull/45252)) ### Other Changes From 097e52bba20f7c3d7ae2c39142bdabf46aeeaad2 Mon Sep 17 00:00:00 2001 From: Radhika Gupta Date: Wed, 18 Feb 2026 16:41:57 -0800 Subject: [PATCH 3/6] Move logic to connection string parser --- .../opentelemetry/exporter/_connection_string_parser.py | 3 +++ .../azure/monitor/opentelemetry/exporter/export/_base.py | 5 +---- 2 files changed, 4 insertions(+), 4 deletions(-) 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 diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py index 4900759a4aef..759ec19cb6fb 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py @@ -120,10 +120,7 @@ def __init__(self, **kwargs: Any) -> None: self._credential = _get_authentication_credential(**kwargs) self._consecutive_redirects = 0 # To prevent circular redirects self._disable_offline_storage = kwargs.get("disable_offline_storage", False) - self._connection_string = ( - parsed_connection_string._connection_string or - os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING", None) - ) + self._connection_string = parsed_connection_string._connection_string self._endpoint = parsed_connection_string.endpoint self._region = parsed_connection_string.region self._instrumentation_key = parsed_connection_string.instrumentation_key From b92dd45eb9235ed5bf95551ce8ebbb23e8933e54 Mon Sep 17 00:00:00 2001 From: Radhika Gupta Date: Thu, 19 Feb 2026 08:23:32 -0800 Subject: [PATCH 4/6] Retrigger CI/CD pipeline From 6fa3bd06f1c30483e7bc7d58f2f1301126d5e037 Mon Sep 17 00:00:00 2001 From: Radhika Gupta Date: Wed, 18 Feb 2026 15:50:33 -0800 Subject: [PATCH 5/6] Fix fallback logic for extracting connection string from env var --- .../azure/monitor/opentelemetry/exporter/export/_base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py index 759ec19cb6fb..4900759a4aef 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py @@ -120,7 +120,10 @@ def __init__(self, **kwargs: Any) -> None: self._credential = _get_authentication_credential(**kwargs) self._consecutive_redirects = 0 # To prevent circular redirects self._disable_offline_storage = kwargs.get("disable_offline_storage", False) - self._connection_string = parsed_connection_string._connection_string + self._connection_string = ( + parsed_connection_string._connection_string or + os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING", None) + ) self._endpoint = parsed_connection_string.endpoint self._region = parsed_connection_string.region self._instrumentation_key = parsed_connection_string.instrumentation_key From 690f9d30f88bfd14f09769531e9c614cdfa4c4f3 Mon Sep 17 00:00:00 2001 From: Radhika Gupta Date: Wed, 18 Feb 2026 16:41:57 -0800 Subject: [PATCH 6/6] Move logic to connection string parser --- .../azure/monitor/opentelemetry/exporter/export/_base.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py index 4900759a4aef..759ec19cb6fb 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py @@ -120,10 +120,7 @@ def __init__(self, **kwargs: Any) -> None: self._credential = _get_authentication_credential(**kwargs) self._consecutive_redirects = 0 # To prevent circular redirects self._disable_offline_storage = kwargs.get("disable_offline_storage", False) - self._connection_string = ( - parsed_connection_string._connection_string or - os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING", None) - ) + self._connection_string = parsed_connection_string._connection_string self._endpoint = parsed_connection_string.endpoint self._region = parsed_connection_string.region self._instrumentation_key = parsed_connection_string.instrumentation_key