Azure functions remote debugging in Visual Studio Code

Amar-Azure-Practice 661 Reputation points
2020-11-06T03:23:17.153+00:00

Hi

I am looking for what are all the available options to debug the remote Azure functions in Visual Studio code.

We have Azure functions developed in C# using Visual Stud code we are able to deploy the Azure functions..

we are able to debug locally but after deploying the Azure functions to Azure we want to debug.

Please let us know what are all the available options.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,890 questions
{count} votes

2 answers

Sort by: Most helpful
  1. JayaC-MSFT 5,531 Reputation points
    2020-11-10T18:07:24.06+00:00

    @Amar-Azure-Practice There is a vscode limitation: https://code.visualstudio.com/docs/editor/debugging#_remote-debugging
    I have also taken this up with VS code product team and they have confirmed that there are currently no plans to support Functions remote debugging in Visual Studio Code.

    2 people found this answer helpful.
    0 comments No comments

  2. sadomovalex 3,631 Reputation points
    2020-11-06T15:10:12.747+00:00

    debug is available when you run Azure functions locally but not on the portal. In the portal you may use functions' trace logs (Run and Test > Log) to see what happens when it runs there. For doing that you will need to add descriptive logging to your code which not only logs errors and warnings but also logs basic information about execution status (current state, return values from internal methods, local variables, etc) to output:

    [FunctionName("MyFunction")]
    public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)]HttpRequestMessage req, TraceWriter log)
    {
        try
        {
            log.Info("Start MyFunction.Run");
            ...
            log.Info("Current state: ...");
            ...
            log.Info("Finish MyFunction.Run");
        }
        catch (Exception ex)
        {
            log.Error($"Error occured: {ex.Message}");
        }
    }
    
    1 person found this answer helpful.

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.