Introduction
Not long ago Microsoft proclaimed to us that they love Linux. And while many remain skeptical of that assertion (and not without reason), the tech giant is continually pouring more time and resources into the open source world. One of the really exciting products of this (to me at least) is PowerShell Core. Not only can I now program with my favorite scripting language from Mac or Linux, I can interact with services like Azure. In fact, Microsoft’s own Azure Cloud Shell runs PowerShell Core, so it’s no side mission for them. Let’s take a look at using it to connect to Azure from a non-Windows environment.
Install PowerShell Core
To start out, we’ll need to install PowerShell Core.
# Download the Microsoft repository GPG keys
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb
# Update the list of products
sudo apt-get update
# Enable the "universe" repositories
sudo add-apt-repository universe
# Install PowerShell
sudo apt-get install -y powershell
# Start PowerShell
pwsh
Now we have PowerShell on Linux!
Next, we will need to install and import the ‘AZ’ module for working with Azure.
Install-Module -Name Az
Import-Module Az
Alright, now we’re ready to rock. Let’s get connected up to Azure using Connect-AzAccount. That will give us a prompt like the one below, supplying a code to be used for connection.
Supply your Azure credentials, and your machine should now be connected.
Now, we can interact with our Azure environment!
Microsoft has done a fantastic job with making PowerShell Core and the Azure cmdlets available on non-Windows systems. It’s a trippy experience to be working with them from Mac or Linux, but I’m excited for the possibilities ahead!
Leave a Reply