Monday, November 19, 2018

5 tools for Azure Development on Linux

If you develop on Azure and Linux, here are 5 tools you should be using.
Photo by Barn Images on Unsplash

Azure may not be the primary choice for developers utilizing non-Microsoft technologies these days but it's important to not ignore it. Especially now that Linux dominates Azure. The always growing number of services, the price, its global reach, the Apis and the features are awesome! If you haven't tried, I'd recommend to test it out and utilize the free credits available for testing. So let's review some of the tools available for developers.

Development - Visual Studio Code

Developing for Azure with Linux is fun! In Windows, my default development editor is Visual Studio. On Linux, I usually use Visual Studio Code for development and Vim for all the rest. VSCode is a multi-platform, extremely customizable IDE with integrated debugger, git and IntelliSense. If you haven't used it yet, I urge you to take a look at the features. Here's what it looks like on Ubuntu:

Installing Visual Studio Code on Ubuntu/Debian-based distributions

The easiest way to install Visual Studio Code for Ubuntu/Debian-based distributions is to download and install the .deb package (64-bit), either through the graphical software center if it's available, or through the command line with:

sudo dpkg -i <file>.deb
sudo apt-get install -f # Install dependencies

Installing Visual Studio Code on RHEL/CentOS/Fedora

In RHEL, CentOS and Fedora, you'll have to add Microsoft's repository, update  the package cache and install it using dnf:
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code] name=Visual Studio Code \
     baseurl=https://packages.microsoft.com/yumrepos/vscode \
     enabled=1 gpgcheck=1 gpgkey=https://packages.microsoft.com/keys/microsoft.asc" \
 > /etc/yum.repos.d/vscode.repo'
dnf check-update
sudo dnf install code

For other distros, different OS or troubleshooting, please check the installation page.

Database - Azure Data Studio

The very popular SQL Server in Azure and on-premises can be accessed via Azure Data Studio. Available for Linux, Windows and Mac, the installation is straightforward, let's take a look.

Installing Azure Data Studio on Debian/Ubuntu systems

Download the executable and run the script below:
cd ~
sudo dpkg -i ./Downloads/azuredatastudio-linux-<version string>.deb
azuredatastudio

Installing Azure Data Studio on RHEL/CentOS/Fedora systems

Download the executable and run the script below:
cd ~
yum install ./Downloads/azuredatastudio-linux-<version string>.rpm
azuredatastudio

In case you need dependencies, please check this page.

Using Azure Sql Data Studio

Once  Azure Sql Data Studio is installed, you're ready to connect to your database. For more detailed information on the topic, please click here.

Storage - Azure Storage Explorer

Azure Storage Explorer is another excellent and fundamental tool for your Azure development. The main features are:
  • queue storage management
  • blob storage management
  • file storage management
  • cosmos db management
  • data lake management

Installation (all Distros)

These are the pre-requisites for the installation:

Download the .tar.gz from the Azure Storage Explorer home page and run:
# install libgnome-keyring (RHEL/CentOS/Fedora specific)
dnf install libgnome-keyring

# extract the files
tar -xvf StorageExplorer-linux-x64.tar.gz

# run it
./StorageExplorer

DevOps - Azure CLI

If you plan or have to building automation scripts that work against the Azure Resource Manager. Azure CLI is the cross-platform tool you need. With the CLI you can do pretty much everything that you can do trough the Azure Portal but trough scripts, from the command line.

Installing the Azure CLI

This page contains the necessary information to install the CLI. Let's quickly review how to install it on Ubuntu/Fedora.

Installing the CLI on Ubuntu

# 1. Modify your sources list
AZ_REPO=$(lsb_release -cs)
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | \
    sudo tee /etc/apt/sources.list.d/azure-cli.list

# 2. Get the Microsoft signing key:
curl -L https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

# 3. Install the CLI:
sudo apt-get update
sudo apt-get install apt-transport-https azure-cli

Installing the Azure CLI on RHEL/CentOS/Fedora

# 1. Import the Microsoft repository key.
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc

# 2. Create local azure-cli repository information.
sudo sh -c 'echo -e "[azure-cli]\nname=Azure CLI\nbaseurl=https://packages.microsoft.com/yumrepos/azure-cli\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/azure-cli.repo'

# 3. Install with the yum install command.
sudo yum install azure-cli

Note: if you already added Microsoft's package repo, you will not need to run step 1.

After steps 1 and 2 above, my local install was as simple as running dnf install azure-cli from the terminal, as root:

And, after running the az command, I get a warm welcome message and am ready to interact with Azure from the command line:

DevOps - Azure PowerShell

Azure PowerShell provides a set of cmdlets to manage your Azure resources. Via a local installation we can interact with Azure using PowerShell. The requirement is... Powershell. Let's see how we can install it on Linux.

Installing PowerShell on Linux

After Adding the Azure-CLI and the Microsoft repos as previously noted, Powershell is available for installation via: dnf install powershell as root, confirm.
After the installation ends, just type pwsh from the terminal and you're running a full PowerShell session (apart from that ugly traditional blue background =))

Once PowerShell is installed, to install the Azure PowerShell modules, simply type Install-Module Az from your PowerShell terminal as root, accept and they you're ready to interact with Azure using PowerShell.

Conclusion

On this post I presented multiple ways we can interface with Azure using extremely productive development tools. We also saw how easy it is to install these tools and quickly build a very powerful development environment. Yes, I know, we have Vim 😁 but sometimes, some nice, extensible and productive tools won't hurt, will they?

References

See Also

About the Author

Bruno Hildenbrand