First use the following commands to setup the Microsoft repo and install Powershell from it:

  • rhel8
  • rhel7
  • ubuntu2004
  • ubuntu1804
1
2
3
curl https://packages.microsoft.com/config/rhel/8/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo
sudo dnf install -y powershell
pwsh

Then install the Azure Powershell module from Powershell using the command below:

PS > Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force

Alternatively if you have docker installed, you can run a container with Azure Powershell directly

docker run -it mcr.microsoft.com/azure-powershell pwsh

Authenticate using Connect-AzAccount -UseDeviceAuthentication, then you should be able to run any commands such as Get-AzVM !

Et voila !