Azure CLI in VSCode
Andrew Posted on 7:59 am

How to Use VS Code for Azure CLI

To keep as much flexibility in my connection and administration work as possible, I like to take advantage of all the hard work of the teams that have given us (the general public) tools like PowerShell, VS Code, and Azure CLI. My clients know that my love of PowerShell is almost equal to that of my mountain biking, but let’s stay focused today! We will walk through getting you setup to use Azure CLI from inside VS Code. This will only take about 15 minutes for you to get up and running, so let’s get started!

  • First, let’s install Azure CLI. Open VS Code and create a new PowerShell document, or open your favourite temporary workspace to use.
  • Install Azure CLI by running the following code:
    Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'
  • Next, install Node JS for your operating system:
NodeJS Download
  • Now we will need to restart VS Code, and maybe for good measure restart your computer to ensure a clean start.
  • Open up VS Code again and press CTRL + SHIFT + P to show the quick select and choose Azure Sign In. Follow the sign in prompts for your Azure Tenant (Get one Free Here)
  • Now press CTRL + SHIFT + P again and choose Azure Subscription. Select your Dev or Testing (or Free) subscription.
  • I promise it’s the last time I’ll ask you to press CTRL + SHIFT + P and this time you finally get to choose Azure Cloud Shell.

Now you can use Azure Cloud Shell to run CLI or PowerShell commands against your selected subscription!

Test it out:

You should see the subscriptions active providers under the Microsoft.Compute heading now.

This is one of my favourite ways to do administration in Azure when I’m on the road. Especially from less secure physical locations such as coffee shops or shared offices. It lets me quickly get into Azure by logging in via a familiar login window (with two factor of course!), and get connected and down to work quickly. It helps with privacy in public spaces as other than those of us who have an interest in computing, command line remains cryptic-looking to passer-bys in the coffee shop.