How to run a Visual Studio Code in Google Cloud Shell?

How to run a Visual Studio Code in Google Cloud Shell?

Tudip

Tudip

22 April 2020

Overview:

Google Cloud Shell is an interactive shell environment for Google Cloud Platform that makes it easy for learning and experimenting with GCP and managing projects and resources from the web browser.

For accessing the Google Cloud Shell we should have familiarity with basic Linux commands and editors.

Imagine running a visual studio code with the help of Google Cloud Shell.

How we can start the process:

  1. Sign in to console.cloud.google.com.
  2. Open cloud Shell. As for opening the cloud shell editor, you will need a codebase. Else for faster execution of commands, you can also use the boost mode in the cloud shell.visual-studio-2Here the most important thing which we need to make clear is our current working directory. Where we are running our script. The most preferable suggestion is to choose the home directory
    Now execute the code given below in the cloud shell editor to install the code server.

    export VERSION=`curl –s https://api.github.com/repos/cdr/code-server/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")'
    
    wget https://github.com/cdr/code-server/releases/download/$VERSION/code-server$VERSION-linux-x64.tar.gz
    
    tar -xvzf code-server$VERSION-linux-x64.tar.gz
    
    cd code-server$VERSION-linux-x64

    visua-studio-3

  3. Once we complete the code in the cloud editor we can now clone and extract the content by using the code given below. ./visual_studio_code.shvisual-studio-4
    Use the ls command to check if our code is extracted in the right directoryvisual-studio-5
    After the successful execution of the code, we can use the following . /code-server –no-auth –port 8080 command to start the server.visual-studio-6
    After completion of this command please check that if we have received the output Connected to the shared process.visual-studio-7
  4. Go to the web preview option and choose the port. We can select the port which has mentioned in this command ./code-server –no-auth –port 8080visual-studio-8
    visual-studio-9
  5. After selecting the web preview option it will redirect to the tab. Where you can see your visual Data Studio.
    It’s easily accessible as we have started this in the cloud shell and also in the home directory. It’s very easy to use Visual Studio via browser as google gives the 5 GB free persistent disk space which can be easily usable and also free.visual-studio-10
  6. Sometimes there can be a case that after being successfully connected to the shared process we may not get the visual studio page in that case. We can edit the web link bt removing authuser=0 from the linkvisual-studio-11

search

Blog Categories

Request a quote