FileNotFoundError: [Errno 2] No such file or directory: ‘/mytriggerxa0_init__.py’

  azure-functions, docker, python, visual-studio-code

Does anyone know why I’m seeing this when I launch the debugger – to attach to a container.

Why doesn’t it say "__init__.py"?
And why can’t it resolve the path?

I’m able to debug the function with F5, but not the container.

Dockerfile:

FROM mcr.microsoft.com/azure-functions/python:3.0-python3.8

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

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

COPY . /home/site/wwwroot

launch.json:

{
            "name": "Python: Remote Attach",
            "type": "python",
            "request": "attach",
            "connect": {
                "host": "localhost",
                "port": 5678
            },
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "."
                }
            ]
        }

Docker-Compose.debug

services:
  qfunc:
    image: qfunc
    build:
      context: .
      dockerfile: ./Dockerfile
    command: ["sh", "-c", "pip install debugpy -t /tmp && python /tmp/debugpy --wait-for-client --listen 0.0.0.0:5678 mytrigger__init__.py "]
    ports:  
      - 5678:5678

Source: Docker Questions

LEAVE A COMMENT