Remote Debugging Azure Functions V2 "The breakpoint will not currently be hit. No symbols have been loaded for this document"

Sometimes it can be tricky to attach the Visual Studio debugger to a deployed Azure Functions app. For example if you use Cloud Explorer you can right click on the deployed Azure Function and choose Attach Debugger as the following screenshot shows:

Using Cloud Explorer to debug an Azure Function

While this may seem to work at first, you may experience a problem with your breakpoints actually being hit when function app code is executing with the message “The breakpoint will not currently be hit. No symbols have been loaded for this document”.

The breakpoint will not currently be hit. No symbols have been loaded for this document

As an alternative to attaching via Cloud Explorer, you can try the following approach:

1 Log in to Azure Portal and navigate to your deployed function app.

2 Download the publish profile

Downloading publish profile for Azure Function app

3 Open the downloaded file

Make a note of the userName, userPWD and destinationAppUrl values.

4 Attach Visual Studio Debugger to Azure Function App

  1. Make sure your function app project is open in Visual Studio
  2. Make sure that you have deployed a debug version of the function app to Azure
  3. On the Debug menu choose Attach to Process..
  4. For the Attach to value, click the Select.. button and un-tick everything except Managed (CoreCLR) code
  5. In the Connection target enter the  destinationAppUrl (without the preceding http) followed by :4022 – for example: investfunctionappdemotest.azurewebsites.net:4022 – and hit Enter
  6. You should now see an Enter Your Credentials popup box, use the userName and userPWD from step 3 and click Ok
  7. Wait a few seconds for Visual Studio to do its thing
  8. Click the w3wp.exe process and the click the Attach button (see screenshot below) Be patient after clicking as it may take quite a while for all the debug symbols to load.

Attaching to the Azure Functions w3wp.exe process

5 Set your breakpoints as desired

Breakpoint set in function run method

6 Invoke your function code and you should see your breakpoint hit

Once again this may take a while so be patient, you may also see “a remote operation is taking longer than expected”.

Azure Function breakpoint being hit in Visual Studio

If you want to fill in the gaps in your C# knowledge be sure to check out my C# Tips and Traps training course from Pluralsight – get started with a free trial.

SHARE:

Comments (13) -

  • John P. Roberts III

    1/24/2019 5:39:04 PM | Reply

    Thanks for this!  It worked perfectly.

    • Jason Roberts

      2/8/2019 2:47:08 AM | Reply

      Cool John - glad to be of help Smile

  • Rbw

    3/13/2019 10:05:56 AM | Reply

    Excellent guide, very helpful, thanks a bunch.

    • Jason Roberts

      3/14/2019 12:02:51 AM | Reply

      Thanks, glad it was useful Smile

  • Rohit Devmore

    5/1/2019 4:15:47 PM | Reply

    thank you, this is great. i had strange issue, where after attaching debugger, I had some code changes, so i stopped debugging and tried to republish app to azure. However i have been getting "file is use" error against dll (even though debugging is stopped ), so i am unable to push changes. Tried to restart webapp with no luck. any suggestions please to release lock on dll?

  • Perry

    6/5/2019 8:41:44 PM | Reply

    This was very helpful.  I was going to spend a long time figuring this out...

    • Jason Roberts

      6/14/2019 5:17:22 AM | Reply

      Awesome Perry, glad to be of help Smile

  • Jeff Breece

    6/25/2019 8:44:57 PM | Reply

    Jason,

    I love the article and how well written it is. So I am following the instructions using Visual Studio 2019. I've launched this super trivial project to an Azure Subscription of my own.

    github.com/jeff-breece/AzureDurableFunction

    I then get the publish settings. Open up Cloud Explorer. I even publish from Visual Studio, gross, thinking that there might be some sort of link between the two. Then I select attach to process, lop off the http:// from the destinationAppUrl and add the ":4022." Pop that into the Connection Target and hit enter. The authentication screen opens up and I enter the full user name domain/$userName and then the full password. Then it spins and returns with a login prompt.

    Any idea of what I am doing wrong? Do I need to somehow classify this as a debug release so it includes some extra dll's?

    Thanks,

    Jeff Breece

    • Jim McG

      8/22/2019 2:34:22 PM | Reply

      I experienced this problem (not able to progress beyond login modal) when using VS2019.  
      Have discovered that making a change in the Azure Portal got things working for me:

      From the Function App Service:

      Configuration -> General Settings  ->  Debugging
      ... and switch over the "Remote Debugging" option to On, selecting the appropriate Visual Studio Option

  • Jan Henzl

    7/16/2020 9:26:12 PM | Reply

    Sounds straightforward, than you.
    But any reason why i get
    "Visual studio was unable to create a secure connection to ... . Authentication failed"
    ?

  • Jan Henzl

    7/16/2020 9:54:36 PM | Reply

    .. aha: Azure Application settings - General Setting - Remote debugging - On

  • Luis

    5/4/2021 1:39:56 AM | Reply

    Thanks for clear and nice article!

    • Jason Roberts

      10/29/2021 3:59:54 AM | Reply

      Thanks Luis - appreciate that Smile

Add comment

Loading