How to Install Visual Studio Code in Azure Virtual

Visual Studio Code (VS Code) is a powerful, open-source code editor beloved by developers for its versatility, customization options, and extensive plugin ecosystem. But what if your development needs to extend to the cloud? Azure virtual machines provide a scalable and secure environment in which to run your applications. The good news is, you can leverage the power of VS Code directly within your Azure VM. This guide will walk you through the installation process, empowering you to develop and manage your cloud-based projects seamlessly within the familiar VS Code interface.

Steps To Install Visual Studio Code in Azure Virtual Machine

To install Visual Studio Code on an Azure Virtual Machine (VM), you can follow these steps:

Requirement:

  • Ensure you have access to an Azure account and the necessary permissions to create and manage VMs.
  • Do you have an existing VM in Azure or are you prepared to create a new one?

Now let’s say you have both an Azure account and valid permissions, now just follow these steps to install visual code or any piece of software in the Azure virtual machine.

1. Create or Access an Azure VM

If you already have a VM, you can skip this step. If you need to create a new one follow these steps:

  • Using Azure Portal
  • Go to the Azure portal.
  • Navigate to “Virtual machines”.
  • Click on create

  • Follow the prompts to create a new VM, here you can customize h/w for your system, storage,location etc.
  • Choose the desired OS (Windows or Linux) and click on create, firstly it will perform validation checks.
  • After validation is passed we can deploy our VM on a single click.

Using Azure CLI:

az vm create --resource-group MyResourceGroup --name MyVM --image UbuntuLTS --admin-username azureuser --generate-ssh-keys

2. Connect to Your VM

For Windows VM:

  • Use Remote Desktop Protocol (RDP) to connect to your Windows VM.

Connecting to VM using Windows RDP:

  • Open your RDP using windows search.
  • Type in public ip address of virtual machine.
  • Ensure that inbound rule allowing TCP traffic on port 3389 you can check this using “Networking” options available in options.
  • Type in username and you will be prompted to enter password enter it.
  • Then you will be connected to your azure virtual machine.

For Linux VM:

Use SSH to connect to your Linux VM.

Open a terminal and use the following command:

ssh azureuser@your-vm-ip

3.Use Vm for Installation

For Windows:

Now just download visual studio code like you would in your windows pc and install it by following steps of installation.

Now you can use VS Code in your Azure VM.

For Linux OS:

Now if you are using Linux OS then you can follow these to install vs code on it:

  • Update the package list and install dependencies:
sudo apt update
sudo apt install software-properties-common apt-transport-https wget
  • Import the Microsoft GPG key:
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
  • Enable the Visual Studio Code repository:
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
  • Update the package list and install Visual Studio Code:
sudo apt update
sudo apt install code
  • Now you can open VS Code on your linux OS.

Install Visual Studio Code in Azure Virtual – FAQs

Which installation method is best for my VM?

There are two main approaches:

Direct Download: This method involves downloading the VS Code installer directly from the official website within your VM and running it. It’s suitable for quick setups but might require additional configuration for specific development environments.

Remote Tunneling: This method leverages VS Code running on your local machine to connect to the VM. It offers a familiar development experience but requires installing the “Remote – Tunnels” extension on both your local VS Code and the VM.

Do I need administrator privileges to install VS Code on the VM?

Yes, administrator privileges are necessary for both installation methods. This allows VS Code to write the necessary files and configurations to your VM.

How can I access VS Code after installation?

  • Direct Download: Once installed, you’ll find the VS Code executable within the chosen installation directory. You can launch it directly from the command line or create a desktop shortcut.
  • Remote Tunneling: With the extension installed on both machines, open VS Code locally and select “Remote + Tunnels” from the command palette. Follow the prompts to connect to your Azure VM.


Contact Us