Skip to content

No logs from CMD when Python file can't load in Docker image #11857

Description

@davetapley

Is your question related to a specific version? If so, please specify:

Docker image:

mcr.microsoft.com/azure-functions/python:4-python3.14

What language does your question apply to? (e.g. C#, JavaScript, Java, All)

Python

Question

With a Dockerfile like:

FROM mcr.microsoft.com/azure-functions/python:4-python3.14

ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true

COPY requirements.txt /
RUN pip install -r /requirements.txt

COPY function_app.py /home/site/wwwroot/

When add this to my function_app.py:

from azure.identity.aio import DefaultAzureCredential
credential = DefaultAzureCredential()

Running goes from this:

WEBSITES_INCLUDE_CLOUD_CERTS is not set to true.
info: Host.Triggers.Warmup[0]
      Initializing Warmup Extension.
info: Host.Startup[503]
...
info: Host.Startup[413]
      Host started (180ms)
info: Host.Startup[0]
      Job host started
Hosting environment: Production
Content root path: /
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.

to this:

WEBSITES_INCLUDE_CLOUD_CERTS is not set to true.
Hosting environment: Production
Content root path: /
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.

And trying to hit any endpoint results on Function host is not running..


In my case the underlying issue was not having aiohttp installed,
but it would be nice to have any log output whatsoever.

It doesn't even tell me there was a problem with function_app.py,
let alone what the problem was.

Invoking manually in the container I could see:

root@09ce4f921168:/# python /home/site/wwwroot/function_app.py 
Traceback (most recent call last):
  File "/opt/python/3/lib/python3.14/site-packages/azure/core/pipeline/transport/__init__.py", line 90, in __getattr__
    from ._aiohttp import AioHttpTransport
  File "/opt/python/3/lib/python3.14/site-packages/azure/core/pipeline/transport/_aiohttp.py", line 49, in <module>
    import aiohttp
ModuleNotFoundError: No module named 'aiohttp'

Can we have this output sent to stdout?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions