Azure Function run in docker compose but debug not working

458 Views Asked by At

I create sample project with Azure functions & Dapr and running in Linux Docker. I use docker compose and yml file to start project. But there are few issues. I'm using VS 2022 and VS code.

First in VS 2022 it will not start for Azure Function project. It works for asp.net Web and API. For Azure Function project it will be getting error as project not support running in Linux. Then I open in VS code command "docker compose up". Projects runs fine, but it was not able to attach debugger on it.

I first tried in VS 2022. followed instruction. I can see my container in list as follows. Select Docker Container Attach to Process After Attached container, it keep runs but not stop at any breakpoint.

Then I tried in VS code, in container I have mount vsdbg to /remote_debugger Here is my docker-compose.yml file

daprfunctester:
image: ${DOCKER_REGISTRY-}daprfunctester
container_name: "daprfunctester"
build:
  context: .
  dockerfile: DaprFuncTester/Dockerfile
environment:
  - DAPR_HTTP_PORT=3500
  - AzureWebJobsStorage
  - DOTNET_USE_POLLING_FILE_WATCHER
  - NUGET_FALLBACK_PACKAGES
  - NUGET_PACKAGES
  - ASPNETCORE_CONTENTROOT=/azure-functions-host
  - FUNCTIONS_WORKER_RUNTIME=dotnet
  - DOTNET_RUNNING_IN_CONTAINER=true
  - PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
volumes:
  - F:\Work\Moneycorp\CodeForFun\DurableForFun:/src
  - C:\Users\winso\vsdbg\vs2017u5:/remote_debugger:rw
  - C:\Users\winso\AppData\Local\AzureFunctionsTools\Containers_2167102\Releases\4.20.0\linuxCLI:/functions_debugging_cli:ro
  - ~/.nuget/packages:/root/.nuget/packages:ro
  - C:\Users\winso\.nuget\packages:/root/.nuget/fallbackpackages:ro     
networks:
  - hello-dapr

And launch.json file

        {
        "name": "Docker .NET Core Attach (Preview)",
        "type": "docker",
        "request": "attach",
        "platform": "netCore",
        "netCore": {
            "debuggerPath": "/remote_debugger/vsdbg",
            //"appProject": "${workspaceFolder}/DaprFuncTester/DaprFuncTester.csproj",
            //"enableDebugging": true
        },
        "sourceFileMap": {
            "/home/site/wwwroot": "${workspaceFolder}/DaprFuncTester"
        },
        "processName": "Microsoft.Azure.WebJobs.Script.WebHost"
        //"processId":"${command:pickProcess}"
    },

When I do F5 run debugger, it was running and if I try to breakpoint, it also stop the Thread due to breakpoint, but it doesn't interact with code, it doesn't indicate or have pointer to the line of code. If press F10 "step over" it will pop error "Failed to step". I don't able to check any variable values. If I check on .Net ThreadPool Worker, it has message "Error processing 'stackTrace' request".

VS code

My question are, it looks from vs code it debugger does stop at breakpoint, why my code doesn't interact? was this something wrong with setting in my launch.json or docker compose files?

0

There are 0 best solutions below