4

I have an Azure WebJob that I created from the WebJobSDK, Service Bus monitor. Basically the WebJob continually monitors a Service Bus, processes the message, and continues looking for new messages. When I debug (F5) the application locally, the process works perfectly. It basically grabs the message from the Bus, transposes it into an XML file, copies that file to an Azure BLOB container, and then call Azure SQL to insert a control row.

My problem is that when I publish the WebJob, I have an error that I don't know how to debug. I can look at the Service Bus messages and see that the process is peeking the message, failing, doing that 9 more times, and then the messages goes into the dead message queue. That is expected when a message is peeked 10 times and never completed (I left this defaulted to 10), so I know my process is running but failing abnormally.

I have Try/Catches around all of my code. What do I need to place within the Catch to have something surfaced in the Azure Portal so I can debug what is wrong? I actually have a call in the catch handler that reads the exception.InnerException and attempts to write it to a DB table, but surprisingly, that never happens.

I appreciate any insight. Thanks a lot...

DanielG
  • 1,669
  • 1
  • 12
  • 26
  • you can do remote debugging with azure webjobs. google around you will find resources which shows step by step how to do it. an example : https://www.opsgility.com/blog/2016/06/22/remote-debugging-azure-web-apps-from-visual-studio/ – akd Oct 14 '17 at 21:38
  • https://blogs.msdn.microsoft.com/webdev/2014/11/12/new-developer-and-debugging-features-for-azure-webjobs-in-visual-studio/ – akd Oct 14 '17 at 21:40

1 Answers1

9

You can do this as follows:

  • In VS, go to Cloud Explorer (make sure you have the latest Azure tools)
  • Find your Web App under App Service
  • Under it, go under WebJobs and find your Continuous WebJob
  • Right Click it and choose Attach Debugger
David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • Thank you very much, David. I found the feature, but when I try to attach to the remote process it complains about a 32-bit, 64-bit conflict. I will work through that, but your advice was bang on. – DanielG Oct 16 '17 at 14:35
  • When expanding "WebJobs" navigation arrow, I get error: "Cloud explorer has encountered an unexpected error: The requested action could not be completed. Details:Invalid Character" – James Wierzba May 09 '18 at 21:20
  • @JamesWierzba if you don't even get as far as expanding WebJobs node, you're running into some different issue. I suggest starting a new question, or a support case. – David Ebbo May 09 '18 at 21:32
  • Seems to be an issue with cloud explorer module. I found a workaround, and opened new Q&A for this: https://stackoverflow.com/questions/50263008/visual-studio-cloud-explorer-error-unexpected-error-the-requested-action/50263058#50263058 – James Wierzba May 09 '18 at 22:42
  • @DanielG Do you remember how you solved the bitness issue? I'm having the same problem. – Koja Jan 24 '19 at 07:29
  • It was not possible for me to debug a Triggered WebJob even if attaching to top AppService – carraua Jul 02 '19 at 10:02
  • Unfortunately it looks like this is no longer an option in VS 2022. It has been retired. https://learn.microsoft.com/en-us/visualstudio/azure/vs-azure-tools-resources-managing-with-cloud-explorer?view=vs-2022 – ChronoZZ Sep 08 '22 at 16:04
  • Cloud Explorer is deprecated – karu Nov 25 '22 at 11:40