Managing Azure with AZ CLI and Windows Subsystem for Linux

Scenario: As a Microsoft developer and engineer, I want to use Linux and Linux tools to manage Azure resources on my Windows 10.

As someone who has been a windows- based developer and IT pro for all of my career, I am starting to need to be more versatile in the tools I use to manage Azure. I normally use PowerShell, but in some cases I see documentation using examples in Az CLI. Even more so, is seeing tutorials and examples in bash scripting along with popular Linux tool such as curl, grep, vim, awk etc. I find I try to

To start from scratch, follow instruction from this documentation Windows Subsystem for Linux Installation Guide for Windows 10. Key steps are outlined as follows.

1) To setup WSL on Windows 10, run as admin:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Or enable

2) From the Microsoft App Store, Install Ubuntu.

3) Run the Ubuntu Application to show the console:

4) To access Linux files in Windows Explorer, run

explorer.exe .

Pretty cool!

5) With VS Code, install Remote – WSL extension.

6) After the install, you will at the bottom left corner a green marker to open a remote shell window

7) Click and open a new window to see the following being prepared

8) And then you got a bash shell in the new VS Code window.

9) Here you can make new script files. I prefer to work in VS Code rather than the Ubuntu console for the reasons of running script files and managing groups of script snippets of executable commands.

10) Install various command line interface tools especially Azure CLI.
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
See my github repo for a script to install my preferred list of tools.
https://github.com/RoyKimYYZ/linux-scripts/blob/master/setup-azure-tools.sh

11) Then begin to login into your azure tenant and subscription and begin to view and manage your azure resources.

Az login
Az account list -o table

Az group list -o table

Az vm list -o table

SSH into the rkLinux Azure VM
ssh azureuser@52.228.39.12

Now I have a shell into the azure Linux VM.

To see my collection of bash shell scripts, visit my Github repo https://github.com/RoyKimYYZ/linux-scripts

Concluding Remarks

I have shown how to setup the tools and the techniques to manage Azure resources from an Ubuntu install via WSL on Windows 10. This gives the ability to have both Linux and Windows consoles in one machine. More so, this opens the door for a dominant windows guy like me to develop my Linux skills and manage Linux-oriented systems and applications on Azure.

Resources

3 thoughts on “Managing Azure with AZ CLI and Windows Subsystem for Linux

  1. Pingback: Managing Azure Kubernetes with Windows Subsystem for Linux – Roy Kim on Azure, Office 365 and SharePoint

  2. Leandro Bulad

    This is nice, Have you tried to SSH into Azure App service? Currently having trouble as SSH’ing into App service requires to tunnel. I’m so new to this thing, and still learning.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s