vscode-azurefunctions: Debugger attaching too late - Unable to hit breakpoints in Startup.cs

In some situations, it looks like the VS Code debugger is unable to attach fast enough to hit specific breakpoints. For example, if we create a boilerplate C# httptriggered Azure function and add a startup.cs file those “early” breakpoints in the file are often missed. Example repo - https://github.com/TroyWitthoeft/AzureFunctionsHostStartupBug

Example of missed breakpoint

76422092-09841600-637b-11ea-863f-e04c2cdf06ef

Above, why didn’t we hit the first breakpoint? Is there anything we can do to correct this? I’ve had quite a few dev’s trying to get started with DI in C# using startup.cs and having this issue.

Note, I am posting here on the suggestion of @WardenGnaw who is assisting me in the csharp extension repo at issue 3644. He mentioned that your team might be able to assist.

Thoughts… Is it possible to change the launch.json file or the ${command:azureFunctions.pickProcess} command to correct for this? Is there someway we can signal to the debugger that we are ready for it to attach?

Environment

VSCode = 1.43.0 Azure Functions Extension = 0.21.0 csharp extension = 1.21.12 azure functions core tools = 3.0.2245

dotnet --info

.NET Core SDK (reflecting any global.json):
 Version:   3.1.102
 Commit:    573d158fea

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.16299
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.1.102\

Host (useful for support):
  Version: 3.1.2
  Commit:  916b5cba26

.NET Core SDKs installed:
  3.1.101 [C:\Program Files\dotnet\sdk]
  3.1.102 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]`

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 10
  • Comments: 16 (3 by maintainers)

Most upvoted comments

For info, I can debug Startup.cs with this configuration in launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Attach to .NET Functions",
      "type": "coreclr",
      "request": "launch",
      "program": "func",
      "args": ["host", "start"],
      "cwd": "${workspaceFolder}/src/Function/bin/Debug/netcoreapp3.1",
     }
  ]
}

Yeah this is somewhat of a known issue. Similar issues for other languages:

We’re currently blocked on this: https://github.com/Azure/azure-functions-host/issues/4384

Neither with no delay, or with long delay. I can’t get the breakpoints in the configure code to hit.