What is your most favorite code editor? The answer for me is Visual Studio Code (aka VS Code), an open-source & cross-platform code editor developed by Microsoft.
I have been actively using Visual Studio Code for over 3 years. My first impression of this tool was its user interface (UI). Visual Studio Code has a UI that looks much the same as Microsoft Visual Studio, my favorite IDE for hard-core development tasks, bringing a seamless user experience so that it helped me to save an amount of time for being familiar with it, especially the layout.
I like to use Visual Studio Code for non-UI software development tasks such as scripting which does not require any fancy SDKs to able to work with.
Locally code in remote Azure Virtual Machine
In one of the projects that I’m currently working on, developers are prohibited from cloning source code directly to their working laptop, each developer is provided with a remote workstation which basically is an Azure Virtual Machine. All source code must be cloned into that remote workstation and their development activities must be done directly in there.
That caused an issue of performance as I have to remote connect to my workstation via RDG and do all development tasks needed via that RDG session. Even having an extremely fast Internet connection with ExpressRoute, working via RDG somehow makes me feel like a snail 🐌.
By deeply digging into the VS Code Extension Marketplace, I found a super cool Visual Studio Code extension named Remote Development, which allows me to do everything I’m currently doing with VS Code in my remote workstation, but locally in my working laptop without going through an RDG session!
Visual Studio Code Remote Development – How it works?
Visual Studio Code Remote Development extension brings you a capability to use a container, remote machine, or the Windows Subsystem for Linux (WSL) as a full-featured development environment. In the scope of this post, I will be focusing on its remote machine support part.
The trick behinds the extension is the SSH tunnel. The extension communicates with the remote machine via an SSH tunnel, giving you an ability to open your remote files and interact with them seamlessly with a “local-quality development experience”.
The following illustration describes a basic flow of the extension:
As you can see in the illustration, the driver for this is VS Code Server, an agent running inside your remote machine to manage all transactions which are made between your local machine and your remote machine via the SSH tunnel.
You don’t need to explicitly set up the VS Code Server as it will be handled automatically by the extension for the first time you connect to your remote machine.
Pros & Cons
- Don’t need to download source code to your local machine to be able to work with.
- Allowing you to continuously work on the same source code across different devices without requiring you to save changes that you made in a device to make it available to other devices.
- Reducing your effort to set up development environment to be able to run or debug your software on different devices.
- Supporting Linux based software development in Windows machines.
I am currently working on multiple types of applications, they require various extensions and frameworks to be installed in my workstation for being able to code & debug. Making a copy of those extensions and frameworks installation across devices is a nightmare to me as it could take a lot of effort and easily be miss-configured. The remote debugging feature is a life vest for my situation. This feature allows me to debug my application remotely without requiring me to install any additional software on my local machine. A consequent benefit of using this feature is to enable you to develop Linux based software right in your Windows machine.
- Requiring a stable Internet connection to avoid interruption.
- Don’t support remembering the password for auto-reconnection.
Since Visual Studio Code Remote Development extension relies on an SSH tunnel, your local machine must be always connected to the Internet to avoid any interruptions. I have been using this extension for over 4 months, the only one thing that annoys me when using this extension is it doesn’t provide a way to remember my password. If my local machine gets disconnected, I will have to type my password manually to be able to get reconnected. The extension currently supports auto-reconnection for SSH key-based authentication only.
Visual Studio Code Remote Development extension is a perfect solution for those who use more than one device to code but want to reduce as much effort in setting up the development environment across devices. More details about this extension including its installation instructions can be found here.