Azure / Azure/azure-functions-host

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

Open
#11,857 1 comment 0 reactions 0 assignees View on GitHub
Needs: Triage (Functions)
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 10h
Merged PRs (30d)
36

Description

#### 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
import aiohttp
ModuleNotFoundError: No module named 'aiohttp'
```

Can we have this output sent to stdout?

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure using the shown Dockerfile and function_app.py, with the missing aiohttp dependency, then trace how the host handles errors while loading the Python file. Check that the import traceback and a clear indication that function_app.py failed to load are emitted to stdout, and verify that endpoint requests no longer fail silently.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, docker, python
Domain
backend, observability
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.