Search code examples
azurevisual-studio-codevscode-remoteazure-cloud-shell

Connecting VScode to Azure Cloudshell




Answer: TLDR: type code . in azure Cloudshell in browser to get file editor. (Using own IDE is not possible, only cloudshell as terminal)


I'm looking to connect VS Code to Azure Cloudshell, especially for the file explorer component.

It is a bit of an anti-pattern, but cloudshell is the only way in which I am able to run some commands that connect to Azure resources (spinning up a VM is not allowed).

I know the 'remote-ssh' extension can connect to a remote machine and provide a nice file explorer, however, for cloudshell I do not have ssh available. However, there is a connection possible through the 'Azure account' extension. (There is also a 'remote tunnel' extension that is able to establish connections over different protocol than ssh).

This is the connection that 'Azure account' sets up with the cloudshell:

Netid  State   Recv-Q   Send-Q     Local Address:Port          Peer Address:Port          Process  
tcp    ESTAB   0        0          10.xxx.xx.169:http-alt      10.xxx.xx.29:57404            
tcp    ESTAB   0        0          10.xxx.xx.169:51710        20.xxx.xx.200:microsoft-ds

Does anybody know if this can be used to get a full remote development experience in VScode connected to Azure cloudshell?

(I tried to install the vs code server rpm package in cloudshell, failed due to lacking yum and sudo permissions.)


Solution

  • Check the below steps to connect to Azure Cloud shell (PowerShell/Bash).

    • Open VSCode, = >Extensions => search for Azure Account. Check whether Azure Account is Installed and Enabled.

    enter image description here

    • If it is not done, Install and Enable it.

    enter image description here

    • We need to Login to Azure Account to Open the Cloud shell.
    • In View tab => Command Palette => Azure: Sign in

    enter image description here

    OR

    Press Ctrl + Shift + P => Azure: Sign in.

    • Click on Sign in and login to Azure. enter image description here

    enter image description here

    • You

    • In the right, click on the dropdown symbol beside + .You will find an option for Azure Cloud shell (PowerShell / Bash).

    • Select Azure Cloud shell (PowerShell) . enter image description here

    • If it is not sign into Azure, you will get an option to Sign in.

    enter image description here

    • Once after Sign, you will get the below message in the terminal. enter image description here

    • To make sure we are connected to Azure Cloud shell, execute any of the PowerShell command and check once.

    enter image description here

    file explorer component

    Thanks @Brendan Burn for the Post.

    Refer this SO Thread regarding File Explorer.