1. Install the Azure CLI Tools extension in vscode
If you don't already have the Azure CLI installed, you can open the link to the landing page directly from vscode (or use the link above):
Choose your platform and install.
2. Start working with the Azure CLI Tools extension in vscode
Once this extension is installed, it's pretty straight forward to get started. I have a lot of files, configurations and common commands that I run on a daily basis with my production and dev tenants; With the support of vscode and the integrated CLI it's easier to ensure correctness in these commands.
2.1 An example: Define an
The vscode extension supports the
.azcli extension, and if you open a file with this extension inside vscode you'll get all the juice and goodness. Here's an example.
Now we've got intellisense directly from the editor. Neat.
But it's not only intellisense for the commands, it's intellisense for your actual resources in Azure too - it'll look it up for you while you're typing, so if you're for example trying to execute the get-version command for an AKS cluster, you don't have to by-heart know the full resource group name and cluster name (and the same obviously goes for any resource in Azure):
Now, you can chose to run your command in the Terminal or in the Editor. I usually execute it in the Terminal (see the shortcut commands for each in the picture below), but sometimes when I need to grab the JSON result, it is very convenient to run it in the Editor.
Run an azcli command in Terminal
In order to get the output directly in the Terminal, all you'll have to do is to execute the "Run Line in Terminal" command; Either by using shortcuts or from the menus. Whatever floats your boat.
Great, quick and easy - superb for troubleshooting and I use this a lot.
Run an azcli command in Editor
But, what is this running in Editor thing? Well, I use this when I need to quickly grab the JSON result of my query and use in any documentation, additional configuration files or REST queries I may need to execute using other means.
Choose the other run option to run in Editor, and you'll get a side by side Editor with first the command being executed, and after a few short moments you'll see the result:
Documentation on mouse-over
Simple things made easier: Now you can just mouse-over any element in the file and it'll display the up to date documentation about this command:
That's a wrap for this short tip. I hope you'll find it as beneficial as I am when working with the CLI on a daily basis.