Azure Functions (.net5) Not able to debug

Ondrej Durica 1 Reputation point
2021-04-21T12:03:49.757+00:00

Hi,
I'm not able to debug locally my azure functions. I was following many articles on microsoft, github etc, but still facing issues.

Environment:

What is happening:

  1. Developer powershell running command: func start --dotnet-isolated-debug or func host start --dotnet-isolated-debug
  2. HttpRequest function is found
  3. Url is shown: http://localhost:7071/api/HttpFunction2
  4. .Net Worker (PID: 53424) is shown
  5. I attach debugger for given process, then I'm able to debug my Main method on Program, where host builder is setup
  6. It goes through the code, but once it touches await host.RunAsync(); it is throwing error "Can't write the message because the call is complete."
  7. Debugger is stopped
  8. I'm trying to ping my functions, which write that function was triggered via api, but then it ends without any log (even one inside of function)
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,012 questions
{count} votes

4 answers

Sort by: Most helpful
  1. Rob Bowman 221 Reputation points
    2021-08-03T12:52:26.127+00:00

    Check that you don't have fiddler running!

    1 person found this answer helpful.
    0 comments No comments

  2. Ondrej Durica 1 Reputation point
    2021-04-22T06:54:02.947+00:00

    Still same issues. Is there anything I could check (debug) inside the code?

    Azure Functions .NET Worker (PID: 28040) initialized in debug mode. Waiting for debugger to attach...
    [2021-04-22T06:52:31.915Z] System.InvalidOperationException: Can't write the message because the call is complete.
    [2021-04-22T06:52:31.917Z] at Microsoft.Azure.Functions.Worker.GrpcWorker.SendStartStreamMessageAsync(IClientStreamWriter`1 requestStream) in C:\srdev\Projects\Functions\azure-functions-dotnet-worker-main\src\DotNetWorker.Grpc\GrpcWorker.cs:line 83
    [2021-04-22T06:52:31.920Z] at Microsoft.Azure.Functions.Worker.WorkerHostedService.StartAsync(CancellationToken cancellationToken) in C:\srdev\Projects\Functions\azure-functions-dotnet-worker-main\src\DotNetWorker.Core\WorkerHostedService.cs:line 25
    [2021-04-22T06:52:31.922Z] at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
    [2021-04-22T06:52:31.923Z] at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
    [2021-04-22T06:52:31.925Z] at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
    [2021-04-22T06:52:31.926Z] at FunctionApp.Program.Main(String[] args) in C:\srdev\Projects\Functions\azure-functions-dotnet-worker-main\samples\FunctionApp\Program.cs:line 35


  3. Jason Wisener 26 Reputation points
    2021-05-25T20:24:41.713+00:00

    In visual studio 2019, we have lost the ability to debug azure 5 functions. What has happened to break this? It's critical we be able to debug our azure functions (5) locally.

    0 comments No comments

  4. Jimmy Karlsson 1 Reputation point
    2021-05-25T22:35:19.923+00:00

    Hi. Initially I had some issues, which was mostly related to proxy settings for an Azure Servicebus trigger function. I got it working by following the official .net 5 instructions at
    https://learn.microsoft.com/en-gb/azure/azure-functions/dotnet-isolated-process-guide

    Currently there is no debug available through vs2019 when running .net 5 functions, so you need to attach the debugger to the dotnet process after you start it in a command or powershell prompt with: func start or func host start (http trigger)


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.