How Cloud Shell Works In VS Code

A recent feature of the VS Code Remote Development extensions is Cloud Shell, which provides a seamless way to take advantage of the Cloud Shell experience, directly from VS Code. What this means is that you can now use Cloud Shell to interact with your Azure resources, and then open up any folder in VS Code to work with your code and services.

How does it work?

The first thing you’ll need to do is install the latest version of the VS Code Remote Development extensions (0.18 or greater) and then you will see a new “Open in Cloud Shell” button on the bottom right corner of your editor window:


Clicking this button will open a new tab that contains an instance of Cloud Shell running in a container within Azure. This container is attached to the same storage account as your instances of Cloud Shell, so all files will persist between sessions.

While Cloud Shell provides lightweight and convenient access to a Linux shell from within the Azure portal, it can be enhanced with the addition of Visual Studio Code. With the VS Code extension Remote – SSH, you can open a remote folder on any remote machine, virtual machine (VM), or container with a running SSH server and take full advantage of VS Code’s feature set.

In this article, we’ll walk through how to use Cloud Shell in VS Code to connect to an Azure VM and quickly edit files live in the browser.

By now, you’ve probably heard of Cloud Shell – a convenient, shell environment that is delivered to your browser. It’s accessed via the Azure Portal, and it provides you with authenticated access to an Ubuntu Linux shell that includes a number of pre-installed common tools. It also automatically mounts Azure file shares into the /clouddrive directory within the bash environment.

The shell is supported in Chrome and Microsoft Edge browsers today, and we have just added support for VS Code.

VS Code has an integrated terminal window where you can run any command-line tool. This feature used to be available by installing an extension from the Marketplace. We recently built this functionality into VS Code itself and are thrilled to announce that it is now available in our 1.28 release!

One of the most powerful and exciting features in the VS Code Remote Development extensions is called Cloud Shell. We’ve talked about it. You’ve seen that image of it. But if you’re anything like me, you might have been a little confused about what exactly it was. So I’m going to try to explain what it is, how it works, and why it’s so cool.

So let’s get started!

Cloud Shell provides an authenticated shell in Azure right from within Visual Studio Code. Using Cloud Shell means no installing or managing software on your local machine, and you can access your environment from anywhere. Cloud Shell is also preconfigured with the latest version of .NET Core along with popular Azure CLI tools such as Terraform and Ansible.

Cloud Shell is a free admin machine that is available instantly within the Azure portal. It works via an SSH connection to your Azure subscription, and it’s equipped with the tools you need to build on the Microsoft stack (think .NET Core, Node.js, Python, Visual Studio Code, Azure CLI, etc.).

The Cloud Shell experience has been built primarily for command line users and developers. But what if you prefer to use a graphical editor?

In this article we’ll show you how to work with Cloud Shell in the context of Visual Studio Code. This is a new extension that was recently made available in preview.

VS Code is an amazing editor. It’s extensible, open-sourced, and has a rich ecosystem of plugins and integrations. One of the most useful features is the ability to connect to remote machines over SSH.

This feature allows you to connect to a remote machine and have full VS Code functionality right on that machine. This is great for when you need to work on a machine that doesn’t have an editor or if you want to use the editor of your choice (hint: VS Code).

Let’s walk through how this works with Azure Cloud Shell and VS Code.

1 – First, you must be connected to Azure using the Azure Account extension for VS Code. If you don’t have it installed yet, you can find it here:

2 – Once connected, you will see a Cloud Shell icon in the left sidebar (if not, click “Show” in the sidebar). Clicking this icon will launch Cloud Shell in a new tab. You will be able to choose between bash or PowerShell as your shell language.

3 – Once Cloud Shell has launched, click on the “Get status bar item” link

It’s now possible to connect to a cloud shell session right from within Visual Studio Code. This opens up a lot of scenarios such as being able to edit and debug your code right from where it is running. You can also connect to a remote terminal and write code on your local machine while using tools and programs installed in the cloud environment.

Here’s how it works:

Once you start Cloud Shell, VS Code will open a new terminal window and connect you to the VM that runs your Cloud Shell instance. From there, you can do any number of things including opening a new file browser window in the current directory by clicking on the Explorer icon next to the new terminal button.

You can also open an SSH tunnel directly from the Terminal menu by entering this command:

ssh -L 80:localhost:80 \$(az account get-access-token –query username)@\$(az account get-access-token –query endpoint).cloudapp.azurestack.external

Leave a Reply

Your email address will not be published.