Azure CLI – Interactive Mode
If you are using the Azure Portal to do some tasks it may be time to take a look at using the Azure CLI (Command Line Interface) as this can be a good way to learn to start automating some tasks. Handily the Azure CLI has an interactive mode.
“You can use Azure CLI in interactive mode by running the
az interactive command. This mode places you in an interactive shell with auto-completion, command descriptions, and examples“
Read the blog post and then checkout my video tutorial at the bottom of the article.
You can read more on the Azure CLI interactive mode docs.
If like me you like to automate tasks (for numerous reasons) then the Azure CLI can be harassed to script out repetitive tasks into lets say a deployment script.
Imagine the scenario where I need to work with Virtual Machines and I want to learn the Azure CLI commands for listing the VM’s I have and then go ahead and create a brand new VM. Lets take a look at how to do that below: –
Create a Resource Group using the Azure CLI
az group create –name myDemoRG –location westeurope
Create a Resource Group using AZ CLI interactive mode
az >> group create –name myDemoRG –location westeurope
The difference here is something called scoping and you can learn about scoping. It’s the same command we type but we don’t need the az at the start as we are currently scoped at the top level.
If you have read about scoping in the above link lets now take a look at working with virtual machines.
Create a Virtual Machine using the Azure CLI
az vm create –resource-group myDemoRG –name myDemoVM –image win2019datacenter –admin-username gsuttie
Create a Virtual Machine using AZ CLI interactive mode
az vm>> create –name myDemoVM –resource-group myDemoRG –image win2019datacenter –admin-username gsuttie
The difference here is something called scoping and you can learn about scoping. It’s the same command but this time in the Azure CLI interactive mode we are scoped to working with Virtual Machines, this is accomplished by typing %%vm and means we can create, list, delete VM’s whilst scoped to using Virtual Machines.
If your not familiar with using the Azure CLI then take a look at trying out the Interactive mode which will give you defaults and examples.
Lear more :-