Azure dev spaces to debug python code running in kubernetes pod

3/20/2019

How to debug the code written in python in container using azure dev spaces for kubernetes ?

-- sushant kumar
azure
containers
kubernetes
python
visual-studio

2 Answers

8/22/2019

Currently debugging in Azure Dev Spaces only lists Node.js, .NET Core, and Java as officially supported. The documentation for how to debug these 3 types of environments was written pretty recently (Quickstarts published on 7/7/2019). I am assuming that a guide for Python should be on the way shortly, but I have been unable to find any published timeline for this.

-- Benjamin Brandt
Source: StackOverflow

3/27/2019

Debugging should be similar just like we have it in Dot net core.In dot net , we used to debug something like this

Setting and using breakpoints for debugging

If Visual Studio 2017 is still connected to your dev space, click the stop button. Open Controllers/HomeController.cs and click somewhere on line 20 to put your cursor there. To set a breakpoint hit F9 or click Debug then Toggle Breakpoint. To start your service in debugging mode in your dev space, hit F5 or click Debug then Start Debugging.

Open your service in a browser and notice no message is displayed. Return to Visual Studio 2017 and observe line 20 is highlighted. The breakpoint you set has paused the service at line 20. To resume the service, hit F5 or click Debug then Continue. Return to your browser and notice the message is now displayed.

While running your service in Kubernetes with a debugger attached, you have full access to debug information such as the call stack, local variables, and exception information.

Remove the breakpoint by putting your cursor on line 20 in Controllers/HomeController.cs and hitting F9.

Try something like this and see if it works.

Here is an article which explains debugging python code in visual studio 2017

https://docs.microsoft.com/en-us/visualstudio/python/tutorial-working-with-python-in-visual-studio-step-04-debugging?view=vs-2017

Hope it helps.

-- Mohit Verma
Source: StackOverflow