Azure command line on OEL

We're working more and more with azure related services at the moment and I've been looking in to the different ways that azure infrastructure can be created/managed other than through the web gui. The web gui is of course fine for basic tasks but we're looking at better ways of automating and reporting on what we have in Azure so have been looking at alternatives.

There are a number of ways to do this including:

1) powershell cmdlets (new to me - but actually powershell seems to have come a really long way and actually seems a very good utility now)
2) azure automation (not gone into it but seems to be a way of wrapping together powershell scripts and some workflow process to create runbooks of automated tasks to be done)
3) azure cli - which is the one I'll talk about

I'm very much a unix person so i wanted whatever automation i came up with to be done from a unix shell - helpfully microsoft provide a command utility called 'azure' (no originality there then) which seems to be able to do prety much anything.

However i was struggling to find how to install this thing - i couldn't find a reference for OEL (the version of unix i'm using) that detailed how to easily install it using packaged installs rather than compiling from source and having to worry about installing all dependencies.

In the end i figured how to do it and the process was fairly simple so i though I'd share it to make other peoples lives easier.

The first problem i had is that the azure client seems to be installed from a package manager called npm (new one on me but does seem to be very popular and what a lot of people are using now) - i needed to get this available but it's not there by default in the OEL7 azure image and not in the default oracle software repositories.

I needed to add a new software repo for this - it seemed the one that was the most trusted is 'EPEL' - see here

To add this as an additional repo for yum to use these are the steps are followed

1. Identify a mirror site where to obtain the epel software package from (this is the package which makes the changes to the repos on your server to enable to to find the extra software required). In my case i used

To pull down the rpm i required i used


which did the following

--2016-04-13 10:14:54--
Resolving (, 2a00:c98:2030:a034::21
Connecting to (||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14524 (14K) [application/x-redhat-package-manager]
Saving to: ‘epel-release-7-5.noarch.rpm’

100%[===============================================================================================================>] 14,524      --.-K/s   in 0.009s

2016-04-13 10:14:54 (1.54 MB/s) - ‘epel-release-7-5.noarch.rpm’ saved [14524/14524]

After it was downloaded i then had to install that using rpm

rpm -ivh epel-release-7-5.noarch.rpm
warning: epel-release-7-5.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:epel-release-7-5                 ################################# [100%]

Now the extra repo is availalable as i can see from this output (very badly formatted here)

 yum repolist
epel/x86_64/metalink                                                                                                              |  27 kB  00:00:00
epel                                                                                                                              | 4.3 kB  00:00:00
(1/3): epel/x86_64/group_gz                                                                                                       | 169 kB  00:00:00
(2/3): epel/x86_64/updateinfo                                                                                                     | 525 kB  00:00:00
(3/3): epel/x86_64/primary_db                                                                                                     | 4.0 MB  00:00:00
repo id                                   repo name                                                                                                status
epel/x86_64                               Extra Packages for Enterprise Linux 7 - x86_64                                                            9,761
ol7_UEKR3/x86_64                          Latest Unbreakable Enterprise Kernel Release 3 for Oracle Linux 7Server (x86_64)                            408
ol7_latest/x86_64                         Oracle Linux 7Server Latest (x86_64)                                                                     14,184
repolist: 24,353

So now i can install the 2 packages i need that will enable me to use npm to install - this is now a simple case of

yum install nodejs npm

this spews out loads of output that i wont paste here.

Now npm is available and i call that to install the azure client app via this command

npm install azure-cli -g

This spews out even more output that the previous one (with lots of random hangs in it) but the eventual result is that azure cli is installed

We can see that from this command output with some nice ascii text art

To link the client up to my azure subscription i then run

 azure login

This pruduced the following output

info:    Executing command login
\info:    To sign in, use a web browser to open the page Enter the code secretcodehere to authenticate.

Going to that url gives this site (in German in this case)

You enter that secret code link to to your azure login and then back at the unix prompt you get

\info:    Added subscription blah blah
info:    Setting subscription blah blah as default

Now everything is set up ready to go

If i run something like this

 azure vm list

I get some nice details

info:    Executing command vm list
+ Getting virtual machines
data:    Name          Status              Location     DNS Name                    IP Address
data:    ------------  ------------------  -----------  --------------------------  ----------
data:    server1       StoppedDeallocated  West Europe
data:    server2        StoppedDeallocated  West Europe

Now i can supposedly do stuff like add vm's directly from a unix command......

The steps to install this were actually only 4 in the end (excluding the login business) - summarized here and removing all the noise and my explanations - so this is the quick way to get it loaded (and the bit i'll no doubt come back and cut and paste in the future).

rpm -ivh epel-release-7-5.noarch.rpm
yum install nodejs npm

npm install azure-cli -g