Friday, March 16, 2018

Azure Tip: Installing and using the Azure CLI in VSCode

1. Install the Azure CLI Tools extension in vscode

Install 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):

Run the AzureCLI Install Command

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 .azcli file

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.

Create an azcli file and see the results

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):

Intellisense on actual resources 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 in Terminal or 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.

Azure CLI executed in Terminal

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:

Command running in Editor

Command result in Editor

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:

Mouse-over documentation in AzureCLI in VSCode

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.

Cheers,
Tobias.


by Tobias Zimmergren via Zimmergren

2 comments:

  1. Nice article I was impressed by seeing this blog, it was very interesting and it is Thanks for sharing all the information with us all.very useful for me. Thank you for sharing any good knowledge and thanks for fantastic efforts. Good information. Thanks for sharing with us
    oracle training in chennai

    oracle training institute in chennai

    oracle training in bangalore

    oracle training in hyderabad

    oracle training

    hadoop training in chennai

    hadoop training in bangalore



    ReplyDelete
  2. I like your post very much. It is very much useful for my research. I hope you to share more info about this. The information which you have provided is very good. It is very useful...
    Salesforce Training in Chennai

    Salesforce Online Training in Chennai

    Salesforce Training in Bangalore

    Salesforce Training in Hyderabad

    Salesforce training in ameerpet

    Salesforce Training in Pune

    Salesforce Online Training

    Salesforce Training

    ReplyDelete