Skip to content

Instantly share code, notes, and snippets.

@alidevhere
Last active August 22, 2022 08:05
Show Gist options
  • Save alidevhere/e3e0e335c78a231b8e0f1443ef3303a7 to your computer and use it in GitHub Desktop.
Save alidevhere/e3e0e335c78a231b8e0f1443ef3303a7 to your computer and use it in GitHub Desktop.

Run Azure Power shell commands from Linux - Ultimate Guide:

Install Powershell on linux

# Update the list of packages
sudo apt-get update

# Install pre-requisite packages.
sudo apt-get install -y wget apt-transport-https software-properties-common

# Download the Microsoft repository GPG keys
wget -q "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb"

# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb

# Update the list of packages after we added packages.microsoft.com
sudo apt-get update

# Install PowerShell
sudo apt-get install -y powershell

Start Power Shell

# Start PowerShell
pwsh

Install Azure CLI in power shell

Install-Module -Name Az -AllowClobber

Update

Update-Module -Name Az  

Import Az module to use azure cli commands

Import-Module Az

Connect You Azure Account

Connect-AzAccount

Run Any command

# this command will show all resources in your account
Get-AzResource
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment