From Ever changing code

< Azure

Install Az PowerShell module

Note az replaced AzureRM that is backwards compatible but both shouldn't be installed at the same time. Official installation guide might come here very handy. Otherwise follow quick steps:

Install Az module and login to Azure cloud

# Verify 
C:\> $PSVersionTable.PSVersion #check required version PowerShell 5.x or 6.x
C:\> Get-InstalledModule -Name Az -AllVersions | select Name,Version
Name Version
---- -------
Az   4.4.0

# Install and import
C:\> Install-Module -Name Az -AllowClobber # admin rights required
C:\> Import-Module Az  # Import the module into the PowerShell session
C:\> Get-Command *az*  # List all available PShell commands

# Login
C:\> Connect-AzAccount # Connect to Azure with a browser sign in token
WARNING: To sign in, use a web browser to open the page and enter the code DAAAAAAAA
to authenticate.

Account          :
SubscriptionName : Microsoft Azure Sponsorship
SubscriptionId   : aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
TenantId         : bbbbbbbb-cccc-dddd-eeee-ffffffffffff
Environment      : AzureCloud

# Update module
C:\> Update-Module -Name Az

Using the module commands to manage resources

PS> help New-AzVM
PS> New-AzVM -Name test-1 -ResourceGroupName 1-149a69-playground-sandbox
cmdlet New-AzVM at command pipeline position 1
Supply values for the following parameters:
User: devops
Password for user devops: **********

PS> Get-AzVM
ResourceGroupName  Name   Location VmSize          OsType    NIC    ProvisioningState Zone
-----------------  ----   -------- ------          ------    ---    ----------------- ----
SANDBOX            test-1 westus   Standard_DS1_v2 Windows   test-1 Succeeded

Install on Linux

Worked on U20.04

sudo apt-get update
sudo apt-get install ca-certificates curl apt-transport-https lsb-release gnupg

curl -sL |
    gpg --dearmor |
    sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null

AZ_REPO=$(lsb_release -cs)
echo "deb [arch=amd64] $AZ_REPO main" |
    sudo tee /etc/apt/sources.list.d/azure-cli.list

sudo apt-get update
sudo apt-get install azure-cli

az login