Using Azure Cloud Shell in Visual Studio Code

VSCode

Over the course of the last year, I have switched over to Visual Studio Code as my defacto code editor. It allows me to create PowerShell scripts, work with my JSON templates for Azure, do some cookbook development with Chef and most of all generate blog articles with markdown.

A few days ago, I read a tweet from Michael Crump about integrating Visual Studio Code with Azure Cloud Shell ,and I thought what I great idea this was.

The article shows how to open Bash in Cloud Shell, but I wanted to open Cloud Shell with PowerShell. The next steps will show you how I integrated Azure Cloud Shell (PowerShell) with Visual Studio Code.

Prerequirements

  1. Install Visual Studio Code
  2. Install Azure Account extension

Sign into Azure in VSCode

  1. Launch Visual Studio Code
  2. Access the Command Palette (Shift-Ctrl-P or click View in the toolbar)
  3. Type: Azure Sign In
  4. You will see a popup that you need to authenticate your device. Click Copy & Open. VSCode
  5. The Device Login page should launch in your browser, the code is in your clipboard and simply paste the code in the textbox. VSCode
  6. Click Continue, follow the steps to authenticate your Azure account, and your device will be authenticated. VSCode

Configure VSCode for Azure Cloud Shell (PowerShell)

  1. Access the Command Palette (Shift-Ctrl-P or click View in the toolbar)
  2. Type: Azure Open PowerShell in Cloud Shell
  3. You will be prompted to download and install Node.js, download the installer that is recommended for most users.
  4. Install Node.js on your device by accepting the defaults and relaunch VSCode.
  5. Open the Command Palette once again and type: Azure Open Powershell in Cloud Shell
  6. Popup will appear informing you that it is “Provisioning PowerShell in Cloud Shell may take a few seconds.” In my case, it felt more like a minute or two. VSCode

If the PowerShell Cloud Shell fails to launch on the first try, just relaunch the Shell, and it should work just fine.

VSCode