Open In App

Microsoft Azure – Introduction to Azure VM Extension

Last Updated : 31 Mar, 2023
Like Article

In this article, we will look into how the Azure Virtual Machines extension for Visual Studio Code works. Let’s use Visual Studio Code to manage our virtual machines in Azure. 

Follow the below steps to use the Azure VM extension in VS Code:

Step 1: First, go to the “Extensions” tab and search for Azure Virtual Machines. Then install it.

After it is installed an Azure icon is added on the left menu as shown below:

Here we already see my Azure subscription here because we are already signed in. You might need to log into your Azure account first and this is a VM that we have in Azure.

From here, we can start and stop it and open it in the Azure portal. We can also add a new SSH key from our local machine. 

Step 2: We can also create a new VM from here. First, we’ll need to enter a name for the VM.

Step 3: Then we need to give in a passphrase, which we used for the SSH key that is going to be generated on our local machine. 

Step 4: Now let’s pick a location for the VM.

It now creates the VM for us. The new VM shows up in the Azure Virtual Machines extension. 

Step 5: Now we can use another Visual Studio Code extension to connect to it with SSH. For the search for the Remote-SSH extension and install it.

Step 6: Now in the “Remote Explorer” menu, we can see my SSH targets. So, right-click on it and connect to it.

Step 7: Then enter the passphrase for the SSH key and we are connected to the VM.

At this point, we have successfully use the VM Extension to connect to Azure.

Now let’s open the VM’s logs to see how it looks:

We can also switch to a terminal and this terminal is connected to the VM. So we can run any commands like the command to see files on the VM as shown below:

You can now work with your Azure Virtual Machines from Visual Studio Code with the Azure Virtual Machines extension for Visual Studio Code. 

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads