Choosing the right tooling for Azure and side by side Azure CLI and PowerShell commands

Pam Lahoud

This article on the various tools available to perform tasks in Azure comes to us from Premier Developer consultant Crystal Tenn.

There are a lot of tools out there for managing your Azure subscriptions! We have the Portal web page, Visual Studio integration (with the Azure SDK), PowerShell commands, and the Azure CLI. Sometimes it’s hard to know which one to use. In all honesty, sometimes the answer is that you choose the one you like the most and use a mixture of other tools for specific tasks because the other tools make it much simpler to accomplish what you are trying to do. As someone who came from a development background and no PowerShell, I tend to rely most on the Azure CLI and a mixture of the other tools depending on the task.

As a general rule of thumb, I recommend that the first time you create a new type of Azure service that you use the Portal so you get a nice view of what is going on and what kinds of options are available for you to specify. I also like to use the Azure Portal for creating SQL databases, Tagging, Scaling, and getting a good overview/management of my resource groups and resources. I would say it’s easiest to deploy an App Service individually using Visual Studio. Creating VMs, Storage, Batch, Containers, and Orchestration are easiest using the Azure CLI, and you can specify options based on the online documentation and adding in parameters as needed.

To get a quicker setup, you may want to stick with command line and use the Azure CLI or PowerShell. Choosing between the two may depend on your background. If you have a strong PowerShell background and you are only using Windows (or Linux and can install PowerShell on it), I would recommend sticking with PowerShell. If you have not used PowerShell before then I recommend learning the Azure CLI. If you want an entirely cross-platform tooling that will work exactly the same on Mac, Linux, and Windows, use the Azure CLI. In general, the Azure CLI tends to be shorter, easier to remember commands, and it is much easier to pick up this language than PowerShell. The PowerShell commands can get quite lengthy.

As a note, both PowerShell and Azure CLI have older versions, so be careful when looking at resources online like guides or documentation. If your Azure CLI command starts with az you are using the current 2.0 version, if it starts with azure you are using the older 1.0 Xplat version. PowerShell commands come in Resource Manager and Service Manager editions. If the command starts with AzureRm you are using the current Resource Manager version, and if it starts with just Azure and has no Rm then you are using the older version that works with the older classic Portal.

Below, I have shared compatible common Azure CLI 2.0 commands that accomplish the same as PowerShell commands (in case you know one method and wanted to see the equivalent command in the other language). Note these are samples of command lines– so you need to know how to use command line to change names, locations, add parameters, and customize them for your system.

Login and Subscription Commands:


Azure CLI Command

PowerShell Command

Login with Web Browser (will always work even if you need two-factor authentication)

az login


Login in CLI (can only use if your account does not need two-factor authentication)

az login -u

Get the subscriptions available

az account list


Set your subscription

az account set –subscription subscriptionId

Select-AzureRmsubscription -TenantId tenantId

List Locations, Resources, Version of CLI, and Help Commands:


Azure CLI Command

PowerShell Command

List all locations

az account list-locations


List all my resource groups

az resource list


List all resources in my resource group

az resource list –resource-group ct-new-rg

Find-AzureRmResource -ResourceGroupNameContains “RGName”

Get what version of the CLI you have

az –version

Get-Module -ListAvailable -Name Azure -Refresh

Get help

az help

Get-Help AzureRM


Get-Help <cmdlet name>

Creating a Resource Group, VM, Storage Commands:


Azure CLI Command

PowerShell Command

Create a Resource group

az group create –name myresourcegroup –location eastus

New-AzureRmResourceGroup -Name TestRG1 -Location “South Central US”

Permanently deletes a resource group

az group delete –name myResourceGroup

Remove-AzureRmResourceGroup -Name TestRG1

Get all available VM sizes

az vm list-sizes –location eastus

Get-AzureRmVmSize -Location “East US” | Sort-Object Name | ft Name, NumberOfCores, MemoryInMB, MaxDataDiskCount -AutoSize

Get all available VM images

az vm image list –output table

Get-AzureRmVMImagesku -Location eastus `

-PublisherName MicrosoftWindowsServer `

-Offer windowsserver

Create a VM

az vm create –resource-group myResourceGroup –name myVM –image win2016datacenter

Go here, the process is lengthy for PowerShell:

Create a Storage account

az storage account create -g myresourcegroup -n mystorageaccount -l eastus –sku Standard_LRS

New-AzureRmStorageAccount -ResourceGroupName TestRG1 -AccountName mystoragename -Type “Standard_LRS” -Location “South Central US”

Managing VMs Commands:


Azure CLI Command

PowerShell Command

List your VMs

az vm list


Start a VM

az vm start –resource-group myResourceGroup –name myVM

Start-AzureRmVM -ResourceGroupName $myResourceGroup -Name $myVM

Stop a VM without deallocating (still charged for stopped VM)

az vm stop –resource-group myResourceGroup –name myVM

Stop-AzureRmVM -StayProvisioned -ResourceGroupName $myResourceGroup -Name $myVM

Stop & Deallocate a VM (no charge for VM that is stopped)

az vm deallocate –resource-group myResourceGroup –name myVM

Stop-AzureRmVM -ResourceGroupName $myResourceGroup -Name $myVM

Restart a running VM

az vm restart –resource-group myResourceGroup –name myVM

Restart-AzureRmVM -ResourceGroupName $myResourceGroup -Name $myVM

Redeploy a VM

az vm redeploy –resource-group myResourceGroup –name myVM

Set-AzureRmVM -Redeploy -ResourceGroupName “myResourceGroup” -Name “myVM”

Delete a VM

az vm delete –resource-group myResourceGroup –name myVM

Remove-AzureRmVM -ResourceGroupName $myResourceGroup -Name $myVM


Discussion is closed.

Feedback usabilla icon