I have been actively using Visual Studio Code (aka VS Code), an open-source & cross-platform code editor developed by Microsoft for over 3 years. This tool is lightweight but what it can do is incredibly amazing. Since the time I first used this tool, it has been my preferred choice for non-UI software development tasks such as Python programing, PowerShell scripting, ARM template authoring that don’t require any fancy SDKs or dev tools to able to work with.
I’m currently working on a project where 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.
However, as you know, working through a remote desktop session is not always a joy. Even having an extremely fast Internet bandwidth, you might still end up with lagging and screaming.
In this post, I’m going to share with you a must-have Visual Studio Code extension that has completely changed the way I work remotely.
Visual Studio Code Remote Development
Visual Studio Code Remote Development is a VS Code extension deployed by Microsoft, bringing you the capability to use a container, remote machine, or the Windows Subsystem for Linux (WSL) as a full-featured development environment.
As of the time of writing, Visual Studio Code Remote Development extension supports 3 different types of remote environments:
- SSH: Allowing you to connect to a remote machine or a virtual machine that has an SSH server running on.
- Container: Allowing you to connect to a Docker container.
- WSL: Allowing you to connect to a Windows Subsystem for Linux (WSL).
Since this post is about sharing my experience so I will be focusing on its remote machine support capability as this was what caught my attention to use this extension.
How it works?
The following illustration describes a basic flow of communication between a local machine and a remote machine using the Visual Studio Code Remote Development extension:
Visual Studio Code Remote Development extension relies on the SSH protocol to establish the connection. When a remote session is requested, an SSH tunnel is created between your local machine and your remote one, from there you can open your remote files and interact with them seamlessly right in your local VS Code with a “local-quality development experience”.
Other than the SSH tunnel, another key component to make this happen is VS Code Server, an agent running inside your remote machine to manage all connections & activities that are made between your local machine and your remote machine through the SSH tunnel.
VS Code Server is a component of the VS Code Remote Development extension and is managed by a VS Code client, 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 using the extension.
Pros & Cons
The following pros & cons were identified based on my experience when I was mainly using RDG & cloning source code to local for development.
- Reducing the risk of distributing source code to multiple devices.
- Allowing you to continuously work on the same source code across different devices without requiring you to sync up your changes between them.
- Reducing your effort in setting up the development environment to be able to run & debug your applications from different devices.
- Giving you the ability to develop Linux based software in a Windows machine.
I am currently working on multiple types of applications with the support of various VS Code extensions and dev tools. Keep track of syncing up those extensions and tools across devices is not an easy task as it could take endless efforts and easily be misconfigured. Fortunately, the extension is capable of sharing VS Code extensions between your remote VS Code and your local one, giving you the ability to code & debug applications using your local VS Code but with the full support from your remote VS Code extensions as if you were working using your remote VS Code.
Another cool benefit of using this extension is it enables you to develop Linux based software right in your Windows machine. I’m a Windows user so working in a Linux workstation is something I’m not comfortable with. Having the support of the VS Code Remote Development extension, I can set up an SSH tunnel from my Windows machine to my remote Linux workstation and start working with the full Windows experience.
- 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 network where both machines can talk to each other to avoid any interruptions. However, comparing to RDG, SSH is much faster obviously.
I have been using this extension for nearly a year, the only thing that kept annoying me when using it was lacking a way to remember my password for unattended auto-reconnection. If the SSH tunnel gets disconnected, I will have to type my password manually again to be able to get reconnected. This limitation is only for password-based authentication, if you are using SSH key-based authentication, the extension fully supports unattended auto-reconnection.
Visual Studio Code Remote Development extension is a must-have solution for those who are seeking for an efficient way to apply the remote development paradigm. More details about this extension including its installation instructions can be found here.