azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

ImportError: cannot import name 'LogData' from 'opentelemetry.sdk._logs' in v1.8.2

Open pietervdheijden opened this issue 4 weeks ago • 23 comments

  • Package Name: azure-monitor-opentelemetry
  • Package Version: 1.8.2
  • Operating System: Ubuntu
  • Python Version: 3.11

Describe the bug After upgrading our Python app to azure-monitor-opentelemetry version 1.8.2, it no longer starts. The behavior looks similar to what’s described in #41996. As a temporary workaround, we downgraded the package to 1.6.13, following the suggestion in that thread. However, that’s not a sustainable long-term fix, so I’m opening this issue to help get the problem addressed in the latest release.

Stack trace:

ImportError: cannot import name 'LogData' from 'opentelemetry.sdk._logs' (/usr/local/lib/python3.11/site-packages/opentelemetry/sdk/_logs/init.py) Process SpawnProcess-2: Traceback (most recent call last): File "/usr/local/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap self.run() File "/usr/local/lib/python3.11/multiprocessing/process.py", line 108, in run self._target(*self._args, **self._kwargs) File "/usr/local/lib/python3.11/site-packages/uvicorn/_subprocess.py", line 78, in subprocess_started target(sockets=sockets) File "/usr/local/lib/python3.11/site-packages/uvicorn/server.py", line 62, in run return asyncio.run(self.serve(sockets=sockets)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "uvloop/loop.pyx", line 1518, in uvloop.loop.Loop.run_until_complete File "/usr/local/lib/python3.11/site-packages/uvicorn/server.py", line 69, in serve config.load() File "/usr/local/lib/python3.11/site-packages/uvicorn/config.py", line 458, in load self.loaded_app = import_from_string(self.app) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/uvicorn/importer.py", line 21, in import_from_string module = importlib.import_module(module_str) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1204, in _gcd_import File "", line 1176, in _find_and_load File "", line 1147, in _find_and_load_unlocked File "", line 690, in _load_unlocked File "", line 940, in exec_module File "", line 241, in _call_with_frames_removed File "/app/src/app.py", line 7, in from *** import *** File "/usr/local/lib/python3.11/site-packages/***.py", line 19, in from ..utils.logger import get_logger File "/usr/local/lib/python3.11/site-packages/***.py", line 267, in logger = get_logger(name) ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/***.py", line 121, in get_logger return LoggerFactory().get(logger_name) ^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/***.py", line 5, in call cls._instances[cls] = super(Singleton, cls).call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/***.py", line 83, in init from azure.monitor.opentelemetry import configure_azure_monitor File "/usr/local/lib/python3.11/site-packages/azure/monitor/opentelemetry/init.py", line 7, in from azure.monitor.opentelemetry._configure import configure_azure_monitor File "/usr/local/lib/python3.11/site-packages/azure/monitor/opentelemetry/_configure.py", line 33, in from azure.monitor.opentelemetry._constants import ( File "/usr/local/lib/python3.11/site-packages/azure/monitor/opentelemetry/_constants.py", line 7, in from azure.monitor.opentelemetry.exporter._constants import ( # pylint: disable=import-error,no-name-in-module File "/usr/local/lib/python3.11/site-packages/azure/monitor/opentelemetry/exporter/init.py", line 7, in from azure.monitor.opentelemetry.exporter.export.logs._exporter import AzureMonitorLogExporter File "/usr/local/lib/python3.11/site-packages/azure/monitor/opentelemetry/exporter/export/logs/_exporter.py", line 14, in from opentelemetry.sdk._logs import LogData ImportError: cannot import name 'LogData' from 'opentelemetry.sdk._logs' (/usr/local/lib/python3.11/site-packages/opentelemetry/sdk/_logs/init.py)

pietervdheijden avatar Dec 03 '25 15:12 pietervdheijden

Same issue here. We did not update azure-monitor-opentelemetry sdk, it already was 1.8.2. But we updated its dependencies:

  • Updating opentelemetry-api (1.38.0 -> 1.39.0)
  • Updating opentelemetry-semantic-conventions (0.59b0 -> 0.60b0)
  • Updating opentelemetry-instrumentation (0.59b0 -> 0.60b0)
  • Updating opentelemetry-util-http (0.59b0 -> 0.60b0)
  • Updating opentelemetry-instrumentation-asgi (0.59b0 -> 0.60b0)
  • Updating opentelemetry-instrumentation-dbapi (0.59b0 -> 0.60b0)
  • Updating opentelemetry-instrumentation-wsgi (0.59b0 -> 0.60b0)
  • Updating opentelemetry-instrumentation-django (0.59b0 -> 0.60b0)
  • Updating opentelemetry-instrumentation-fastapi (0.59b0 -> 0.60b0)
  • Updating opentelemetry-instrumentation-flask (0.59b0 -> 0.60b0)
  • Updating opentelemetry-instrumentation-psycopg2 (0.59b0 -> 0.60b0)
  • Updating opentelemetry-instrumentation-requests (0.59b0 -> 0.60b0)
  • Updating opentelemetry-instrumentation-urllib (0.59b0 -> 0.60b0)
  • Updating opentelemetry-instrumentation-urllib3 (0.59b0 -> 0.60b0)

I temporarely fixed by forcing opentelemetry-api v1.38.0

francescopagano3 avatar Dec 03 '25 15:12 francescopagano3

This is definitely an issue with the new azure-monitor-opentelemetry version. After running into the same error above, I was able to overcome it by pinning to a specific version. I.e. azure-monitor-opentelemetry==1.8.1

dmensah1 avatar Dec 03 '25 16:12 dmensah1

@pietervdheijden Thank you for bringing this up. We will release a new version of azure-monitor-opentelemetry tomorrow that will use the OTEL version which is stable while we continue to get breaking changes from opentelemetry. Will keep you posted once release is done and ready to be used.

rads-1996 avatar Dec 03 '25 18:12 rads-1996

This broke my team's builds as well. The problem is actually in the Azure code here, not OpenTelemtry SDK. It's improper to import private (_ prefix) resources from packages/modules you do not directly own.

doubleyewdee avatar Dec 03 '25 19:12 doubleyewdee

Azure-monitor-opentelemetry should place a constraint on the required version of opentelemetry-sdk. I noticed that the new opentelemetry-sdk 1.39.0 removed LogData class from init.py exports under _logs.

kuzhao avatar Dec 03 '25 20:12 kuzhao

@pietervdheijden Thank you for bringing this up. We will release a new version of azure-monitor-opentelemetry tomorrow that will use the OTEL version which is stable while we continue to get breaking changes from opentelemetry. Will keep you posted once release is done and ready to be used.

Hello @rads-1996 , Do you have any news about the release of azure-monitor-opentelemetry correcting the issue ?

izvictor avatar Dec 04 '25 14:12 izvictor

We have faced the same issue as well, running a Django app on Python 3.12 on Azure Web App

OverTheCorner avatar Dec 04 '25 14:12 OverTheCorner

@rads-1996 Can we get an update on this? Today, my Function App deployments are failing on Azure with the below stack trace, which seem to be coming from just importing configure_azure_monitor from azure.monitor.opentelemetry.

Error trace:

Result: Failure Type: Exception: StopIteration: Stack: File "/azure-functions-host/workers/python/3.12/LINUX/X64/azure_functions_worker/dispatcher.py", line 485, in _handle__functions_metadata_request self.load_function_metadata( File "/azure-functions-host/workers/python/3.12/LINUX/X64/azure_functions_worker/dispatcher.py", line 465, in load_function_metadata self.index_functions(function_path, function_app_directory))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/azure-functions-host/workers/python/3.12/LINUX/X64/azure_functions_worker/dispatcher.py", line 847, in index_functions indexed_functions = loader.index_function_app(function_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/azure-functions-host/workers/python/3.12/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 44, in call return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/azure-functions-host/workers/python/3.12/LINUX/X64/azure_functions_worker/loader.py", line 244, in index_function_app imported_module = importlib.import_module(module_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/python/3/lib/python3.12/importlib/init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1331, in _find_and_load_unlocked File "", line 935, in _load_unlocked File "", line 999, in exec_module File "", line 488, in _call_with_frames_removed File "/home/site/wwwroot/function_app.py", line 11, in from azure.monitor.opentelemetry import configure_azure_monitor File "/home/site/wwwroot/azure/monitor/opentelemetry/init.py", line 7, in from azure.monitor.opentelemetry._configure import configure_azure_monitor File "/home/site/wwwroot/azure/monitor/opentelemetry/_configure.py", line 10, in from opentelemetry.instrumentation.instrumentor import ( # type: ignore File "/home/site/wwwroot/opentelemetry/instrumentation/instrumentor.py", line 26, in from opentelemetry.instrumentation._semconv import ( File "/home/site/wwwroot/opentelemetry/instrumentation/_semconv.py", line 19, in from opentelemetry.instrumentation.utils import http_status_to_status_code File "/home/site/wwwroot/opentelemetry/instrumentation/utils.py", line 25, in from opentelemetry import context, trace File "/home/site/wwwroot/opentelemetry/context/init.py", line 70, in _RUNTIME_CONTEXT = _load_runtime_context() ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/site/wwwroot/opentelemetry/context/init.py", line 60, in _load_runtime_context return next( # type: ignore ^^^^^^^^^^^^^^^^^^^^^

dmensah1 avatar Dec 04 '25 15:12 dmensah1

@dmensah1 We are going to be releasing the new version of azure-monitor-opentelemetry today. I will post a comment here once the release is done and the new version can be used. Until then please use opentelemetry-sdk version 1.38. Thank you for your patience.

rads-1996 avatar Dec 04 '25 15:12 rads-1996

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @gulopesd @Haiying-MSFT @jairmyree @joshfree @KarishmaGhiya @KevinBlasko @kurtzeborn @pvaneck @scottaddie @srnagar @ToddKingMSFT.

github-actions[bot] avatar Dec 04 '25 16:12 github-actions[bot]

Looks like these releases are never being tested. We had the kind of issue some months ago on release v1.32.

BTW, here is breaking on azure-monitor-opentelemetry == 1.6.7. See the stack trace below:

Traceback (most recent call last): File "/code/main.py", line 1, in from mylib.helpers.metrics.AzureApplicationInsightsMetricsHelper import AzureApplicationInsightsMetricsHelper File "/usr/local/lib/python3.12/site-packages/caspian_sdk/helpers/metrics/AzureApplicationInsightsMetricsHelper.py", line 1, in from azure.monitor.opentelemetry import configure_azure_monitor File "/usr/local/lib/python3.12/site-packages/azure/monitor/opentelemetry/init.py", line 7, in from azure.monitor.opentelemetry._configure import configure_azure_monitor File "/usr/local/lib/python3.12/site-packages/azure/monitor/opentelemetry/_configure.py", line 33, in from azure.monitor.opentelemetry._constants import ( File "/usr/local/lib/python3.12/site-packages/azure/monitor/opentelemetry/_constants.py", line 7, in from azure.monitor.opentelemetry.exporter._constants import ( # pylint: disable=import-error,no-name-in-module File "/usr/local/lib/python3.12/site-packages/azure/monitor/opentelemetry/exporter/init.py", line 7, in from azure.monitor.opentelemetry.exporter.export.logs._exporter import AzureMonitorLogExporter File "/usr/local/lib/python3.12/site-packages/azure/monitor/opentelemetry/exporter/export/logs/_exporter.py", line 14, in from opentelemetry.sdk._logs import LogData ImportError: cannot import name 'LogData' from 'opentelemetry.sdk._logs' (/usr/local/lib/python3.12/site-packages/opentelemetry/sdk/_logs/init.py)

Jricard0 avatar Dec 04 '25 22:12 Jricard0

@pietervdheijden, @kuzhao, @doubleyewdee, @Jricard0, @dmensah1, @francescopagano3, @OverTheCorner, @izvictor We have released azure-monitor-opentelemetry version 1.8.3, please use that and let us know in case of any issues.

rads-1996 avatar Dec 05 '25 01:12 rads-1996

Hi @pietervdheijden. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

github-actions[bot] avatar Dec 05 '25 01:12 github-actions[bot]

Hi @rads-1996 ,

I upgraded my dependencies now to azure-monitor-opentelemetry 1.8.3, but the error still persists on my side.

  - Updating opentelemetry-api (1.38.0 -> 1.39.0)
  - Updating opentelemetry-semantic-conventions (0.59b0 -> 0.60b0)
  - Updating opentelemetry-instrumentation (0.59b0 -> 0.60b0)
  - Updating opentelemetry-util-http (0.59b0 -> 0.60b0)
  - Updating opentelemetry-instrumentation-asgi (0.59b0 -> 0.60b0)
  - Updating opentelemetry-instrumentation-dbapi (0.59b0 -> 0.60b0)
  - Updating opentelemetry-instrumentation-wsgi (0.59b0 -> 0.60b0)
  - Updating opentelemetry-proto (1.38.0 -> 1.39.0)
  - Updating opentelemetry-sdk (1.38.0 -> 1.39.0)
  - Updating azure-monitor-opentelemetry-exporter (1.0.0b45 -> 1.0.0b46)
  - Updating opentelemetry-exporter-otlp-proto-common (1.38.0 -> 1.39.0)
  - Updating opentelemetry-instrumentation-django (0.59b0 -> 0.60b0)
  - Updating opentelemetry-instrumentation-fastapi (0.59b0 -> 0.60b0)
  - Updating opentelemetry-instrumentation-flask (0.59b0 -> 0.60b0)
  - Updating opentelemetry-instrumentation-psycopg2 (0.59b0 -> 0.60b0)
  - Updating opentelemetry-instrumentation-requests (0.59b0 -> 0.60b0)
  - Updating opentelemetry-instrumentation-urllib (0.59b0 -> 0.60b0)
  - Updating opentelemetry-instrumentation-urllib3 (0.59b0 -> 0.60b0)
  - Updating azure-monitor-opentelemetry (1.8.2 -> 1.8.3)
  - Updating opentelemetry-exporter-otlp-proto-http (1.38.0 -> 1.39.0)
  - Updating trove-classifiers (2025.11.14.15 -> 2025.12.1.14)

Edit: I found that I can only solve this by pinning the version of opentelemetry-sdk to 1.39.0 as suggested by @kuzhao .

GrazingScientist avatar Dec 05 '25 08:12 GrazingScientist

azure-monitor-opentelemetry 1.8.3 appears to be working for me.

daviddavis avatar Dec 05 '25 15:12 daviddavis

Hi @rads-1996 ,

I upgraded my dependencies now to azure-monitor-opentelemetry 1.8.3, but the error still persists on my side.

  - Updating opentelemetry-api (1.38.0 -> 1.39.0)
  - Updating opentelemetry-semantic-conventions (0.59b0 -> 0.60b0)
  - Updating opentelemetry-instrumentation (0.59b0 -> 0.60b0)
  - Updating opentelemetry-util-http (0.59b0 -> 0.60b0)
  - Updating opentelemetry-instrumentation-asgi (0.59b0 -> 0.60b0)
  - Updating opentelemetry-instrumentation-dbapi (0.59b0 -> 0.60b0)
  - Updating opentelemetry-instrumentation-wsgi (0.59b0 -> 0.60b0)
  - Updating opentelemetry-proto (1.38.0 -> 1.39.0)
  - Updating opentelemetry-sdk (1.38.0 -> 1.39.0)
  - Updating azure-monitor-opentelemetry-exporter (1.0.0b45 -> 1.0.0b46)
  - Updating opentelemetry-exporter-otlp-proto-common (1.38.0 -> 1.39.0)
  - Updating opentelemetry-instrumentation-django (0.59b0 -> 0.60b0)
  - Updating opentelemetry-instrumentation-fastapi (0.59b0 -> 0.60b0)
  - Updating opentelemetry-instrumentation-flask (0.59b0 -> 0.60b0)
  - Updating opentelemetry-instrumentation-psycopg2 (0.59b0 -> 0.60b0)
  - Updating opentelemetry-instrumentation-requests (0.59b0 -> 0.60b0)
  - Updating opentelemetry-instrumentation-urllib (0.59b0 -> 0.60b0)
  - Updating opentelemetry-instrumentation-urllib3 (0.59b0 -> 0.60b0)
  - Updating azure-monitor-opentelemetry (1.8.2 -> 1.8.3)
  - Updating opentelemetry-exporter-otlp-proto-http (1.38.0 -> 1.39.0)
  - Updating trove-classifiers (2025.11.14.15 -> 2025.12.1.14)

Edit: I found that I can only solve this by pinning the version of opentelemetry-sdk to 1.39.0 as suggested by @kuzhao .

I think if you are using a virtual environment sometimes, pip uses the cached version of the previous package and even though azure-monitor-opentelemetry v1.8.3 tries to install opentelemetry-sdk v1.39, it tries to uninstall the new version and use the previous version which is what might have happened in your case. You could try clearing the installed packages and then install the newer version of azure-monitor-opentelemetry and then do a pip list right after to make sure version 1.39 of the otel package gets installed.

rads-1996 avatar Dec 05 '25 15:12 rads-1996

@pietervdheijden, @kuzhao, @doubleyewdee, @Jricard0, @dmensah1, @francescopagano3, @OverTheCorner, @izvictor We have released azure-monitor-opentelemetry version 1.8.3, please use that and let us know in case of any issues.

@rads-1996 Worked for us thanks. Regrads,

izvictor avatar Dec 05 '25 21:12 izvictor

Hi,

azure-monitor-opentelemetry version 1.8.3 is also working for us. However, some events are being missed, which did not happen when we were using version 1.8.1. This is our code for sending events to Application Insights. We call the send_custom_event function several times in our executions (jobs in Databricks):

from azure.monitor.events.extension import track_event
from azure.monitor.opentelemetry import configure_azure_monitor
from opentelemetry._logs import get_logger_provider

def create_azure_connection():
    connection_string = get_applicationinsights_connection_string()
    configure_azure_monitor(connection_string=connection_string)

def send_custom_event(event_name, message_dict):
    create_azure_connection()
    track_event(event_name, message_dict)
    get_logger_provider().force_flush()
    print(f"Event '{event_name}' tracked")

Has something changed with the new version?

Thanks!

leireroman12 avatar Dec 09 '25 08:12 leireroman12

@pietervdheijden, @kuzhao, @doubleyewdee, @Jricard0, @dmensah1, @francescopagano3, @OverTheCorner, @izvictor We have released azure-monitor-opentelemetry version 1.8.3, please use that and let us know in case of any issues.

@rads-1996 it seems to work now, thanks (also, we don't use custom events)

francescopagano3 avatar Dec 09 '25 15:12 francescopagano3

Hi,

azure-monitor-opentelemetry version 1.8.3 is also working for us. However, some events are being missed, which did not happen when we were using version 1.8.1. This is our code for sending events to Application Insights. We call the send_custom_event function several times in our executions (jobs in Databricks):

from azure.monitor.events.extension import track_event
from azure.monitor.opentelemetry import configure_azure_monitor
from opentelemetry._logs import get_logger_provider

def create_azure_connection():
    connection_string = get_applicationinsights_connection_string()
    configure_azure_monitor(connection_string=connection_string)

def send_custom_event(event_name, message_dict):
    create_azure_connection()
    track_event(event_name, message_dict)
    get_logger_provider().force_flush()
    print(f"Event '{event_name}' tracked")

Has something changed with the new version?

Thanks!

@leireroman12 Do you mind opening a separate issue in this repo. No changes to events have been made in this upgrade. However, we can investigate this separately. Please consider providing a repro if possible, with pip freeze and any other environment setup. Screenshots from application insights will also be useful.

rads-1996 avatar Dec 09 '25 16:12 rads-1996

Hi, azure-monitor-opentelemetry version 1.8.3 is also working for us. However, some events are being missed, which did not happen when we were using version 1.8.1. This is our code for sending events to Application Insights. We call the send_custom_event function several times in our executions (jobs in Databricks):

from azure.monitor.events.extension import track_event
from azure.monitor.opentelemetry import configure_azure_monitor
from opentelemetry._logs import get_logger_provider

def create_azure_connection():
    connection_string = get_applicationinsights_connection_string()
    configure_azure_monitor(connection_string=connection_string)

def send_custom_event(event_name, message_dict):
    create_azure_connection()
    track_event(event_name, message_dict)
    get_logger_provider().force_flush()
    print(f"Event '{event_name}' tracked")

Has something changed with the new version? Thanks!

@leireroman12 Do you mind opening a separate issue in this repo. No changes to events have been made in this upgrade. However, we can investigate this separately. Please consider providing a repro if possible, with pip freeze and any other environment setup. Screenshots from application insights will also be useful.

Hi rads-1996, Thank you for your reply. I've created issue https://github.com/Azure/azure-sdk-for-python/issues/44358

leireroman12 avatar Dec 10 '25 07:12 leireroman12

Nobody from MS has addressed @doubleyewdee 's comment, and that's a problem. When the opentelemetry-sdk developers put implementation details behind "_" that is a signal from them that those details are not for public consumption.

It is irresponsible for MS developers to use this import in the first place, and it is even more so to blame those developers when you fail to heed their warning.

The version pinning introduced in the new release might resolve the error message, but it does not fix the underlying problem.

vtechev avatar Dec 11 '25 00:12 vtechev

The OpenTelemetry logging API/SDK is not stable and hence marked with '_'. Since azure-monitor-opentelemetry takes its dependencies on OTEL, we import the required classes, interfaces, etc. from the logging API/SDK. It is very close to being stable, and you can review the proposed stabilization plan here: https://github.com/open-telemetry/opentelemetry-python/issues/4750, post that we’ll be able to reference it directly.

rads-1996 avatar Dec 11 '25 18:12 rads-1996

@rads-1996 Can we get an update on this? Today, my Function App deployments are failing on Azure with the below stack trace, which seem to be coming from just importing configure_azure_monitor from azure.monitor.opentelemetry.

Error trace:

Result: Failure Type: Exception: StopIteration: Stack: File "/azure-functions-host/workers/python/3.12/LINUX/X64/azure_functions_worker/dispatcher.py", line 485, in _handle__functions_metadata_request self.load_function_metadata( File "/azure-functions-host/workers/python/3.12/LINUX/X64/azure_functions_worker/dispatcher.py", line 465, in load_function_metadata self.index_functions(function_path, function_app_directory)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/azure-functions-host/workers/python/3.12/LINUX/X64/azure_functions_worker/dispatcher.py", line 847, in index_functions indexed_functions = loader.index_function_app(function_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/azure-functions-host/workers/python/3.12/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 44, in call return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/azure-functions-host/workers/python/3.12/LINUX/X64/azure_functions_worker/loader.py", line 244, in index_function_app imported_module = importlib.import_module(module_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/python/3/lib/python3.12/importlib/init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1331, in _find_and_load_unlocked File "", line 935, in _load_unlocked File "", line 999, in exec_module File "", line 488, in _call_with_frames_removed File "/home/site/wwwroot/function_app.py", line 11, in from azure.monitor.opentelemetry import configure_azure_monitor File "/home/site/wwwroot/azure/monitor/opentelemetry/init.py", line 7, in from azure.monitor.opentelemetry._configure import configure_azure_monitor File "/home/site/wwwroot/azure/monitor/opentelemetry/_configure.py", line 10, in from opentelemetry.instrumentation.instrumentor import ( # type: ignore File "/home/site/wwwroot/opentelemetry/instrumentation/instrumentor.py", line 26, in from opentelemetry.instrumentation._semconv import ( File "/home/site/wwwroot/opentelemetry/instrumentation/_semconv.py", line 19, in from opentelemetry.instrumentation.utils import http_status_to_status_code File "/home/site/wwwroot/opentelemetry/instrumentation/utils.py", line 25, in from opentelemetry import context, trace File "/home/site/wwwroot/opentelemetry/context/init.py", line 70, in _RUNTIME_CONTEXT = _load_runtime_context() ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/site/wwwroot/opentelemetry/context/init.py", line 60, in _load_runtime_context return next( # type: ignore ^^^^^^^^^^^^^^^^^^^^^

I was able to resolve this by applying the following application settings: https://learn.microsoft.com/en-us/azure/azure-functions/functions-deployment-technologies?tabs=linux#remote-build

Everything was working perfectly when run localy on windows and in a Linux Consumption Function App. My problem was that we were using a Function app running on Linux in a Premium Plan without the above settings. I can only say that in this case, for some reason, it is not enough to install all dependencies prior to release. You have to enable remote build to make it work.

o-lovgren avatar Dec 18 '25 09:12 o-lovgren