How to run a Visual Studio Code in Google Cloud Shell?
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:
- Sign in to console.cloud.google.com.
- 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.Here 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
- 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.sh
Use the ls command to check if our code is extracted in the right directory
After the successful execution of the code, we can use the following . /code-server –no-auth –port 8080 command to start the server.
After completion of this command please check that if we have received the output Connected to the shared process.
- 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 8080
- 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.
- 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 link