Tailored cloud financial management solutions.
Manage the end-to-end delivery of IT services to customers successfully.
Complete cloud migration services for the public sector.
Transforming the financial services sector with industry-leading cloud and data solutions.
Delivering compliant and secure cloud automation solutions for the Public sector.
Other sectors that we currently have clients within include insurance, media, retail, construction and automotive.
Our team of industry-leading experts deliver world-leading transformation solutions.
We would love to talk about transforming your business. Please let us know.
Our latest industry news, insights, employee stories, and upcoming events.
2020-09-10 00:00:00
I’ve been doing a fair amount of work recently involving Azure Functions using Python. Microsoft seem quite keen for us to use Visual Studio Code. I’m not so keen. I want to use PyCharm, but it took me a while to figure out how to get a debugger wired up. Hopefully this little demo will save the pain I went through. It turns out, like so many things, it’s easy when you know how. The secret is starting a remote debugger and connecting to it early in your Azure Function code.
In the terminal, initialize a new project, also installing the pydevd-pycharm
package at the same time.
python -m venv venv
. ./venv/bin/activate
func init debugdemo -—worker-runtime python
cd debugdemo
func new --template “Http Trigger” --name debug
pip install pydevd-pycharm
Open the project in PyCharm. Add the virtual environment which was created above as the project interpreter (File→Settings→Project→Python Interpreter):
Add a new debug configuration of type ‘Python Debug Server’. Set your host name and port as required (note that we already installed the pydevd-pycharm package when we initialized the app):
Edit the function code, right at the top, include the code shown in the screenshot, e.g:
import pydevd_pycharm
pydevd_pycharm.settrace("localhost", port=12345, stdoutToServer=True, stderrToServer=True)
Start the debugger, set a breakpoint, then back in the terminal run func start
as normal, and that’s it. Your breakpoint will be hit. Just remember to remove the code when you’re done.
Like I said, easy when you know how.