Share via


Azure from a Linux (MAC) Environment–Install Linux, Install Azure CLI and work with Azure (SUSE)

 

A few colleagues of mine and customers I work with are complete Linux folks. They wanted a Step by Step on how to work from a Linux environment and create resources in Azure. This is for them and as well as for my own reference.

Install Linux

1. Download any flavor of Linux and install it either on your box or run it virtualized. For those who are already running Linux as their main environment, you don’t have to.

I installed openSUSe13.2

clip_image002

Installing Azure CLI for Linux

Once you have the OS, download the Azure Cross Platform Command Line Interface aka xplat CLI and install it. You will see the download in the “Download” folder as shown below. On any browser search for Azure XPLAT CLI. You should be taken to the link to download the Azure CLI.

Note that though I am not explicitly showing for a MAC, if you have a MAC and installed the Azure CLI binary for a MAC ( links here - https://azure.microsoft.com/en-us/documentation/articles/xplat-cli-install/ ) you should be able to use the same set of Azure CLI commands to work from a MAC.

Now onto SuSE Linux.

 

clip_image004

Install Node package

Before we do anything we need Node.js in the Linux box, as Azure CLI is implemented on top of Node.js. So following screen shows how to get the Node Package Manager (NPM) onto your Linux box.

sudo zypper install npm (Note that I am showing for SuSE Linux. This might vary for other flavors of Linux).

clip_image005

Install Azure CLI

Next step is to install the Azure CLI after Node.js has been installed.

sudo npm install –g azure-cli clip_image007 clip_image008

Check out Azure Xplat CLI now

After the Azure CLI has been installed, you can check out the various Azure commands available to you by just typing “azure” on the command window as shown below.

clip_image010

Logging into your azure account

Before you do anything you should be logged into your Azure account, OR rather you should have a permitted way of working with your azure account. This assumes you have an azure account. If not you can go to https://portal.azure.com and sign up for one.

azure login <loginID>” clip_image011

 

Note that, if for some reason you are unable to login try the following to clear the account cache and try again.

azure account clear

-> yes

azure login

Setting your Azure Account

Then download your account – the command is shown below.

azure account download

clip_image012

I was not able to download it, hence I went to the URL above (in yellow)  and directly downloaded it from the browser.

clip_image014

Then you will have your publishsettings file in the “Downloads” folder as shown below which you then import.

clip_image016

The command to import is

azure account import <full-path-to-publish-settings-file> . This is shown in the screen shot below, in working with VMs. You will have to zoom to see it.

Working with VMs

List VM images and then create a VM

1. Find list of Suse Linux images using

gpillai@linux-a4su->azure vm images list | grep –i suse

 

This will list the VM images for suse as shown below. Pick one of them to create your VM.

clip_image018

Create the VM

Note that you will need to have a cloudService into which to deploy the VM OR specify a location where it will create a default CloudService which bears the same name as your VM name. Otherwise it will error out as shown below.

gpillai@linux-a4su->azure vm create <VMNAME> <IMAGE_TO_BEUSED> username –l <Location>

 

In my case I used the following:- (see screen shot below)

<VMNAME> = testsusevm

<IMAGE_TO_BE_USED> = b4590dxxxxx-v20150512 (shortened the full name, but you can see it in the screenshot.

<Location> = ‘south Central US’

As you can see, I did not give the location first and it failed. Then I listed the available locations using the command, and then picked 'South Central US'.

azure vm location list clip_image020

Now login to the Azure portal. You will be able to see the VM being provisioned OR fully created.

clip_image022

Once the Linux VM is created, you should be able to remote into it and start using it. You might want to open up a SSH end point to the Linux VM. For this go to the specific VM, and then the “endpoints” tab and click “Add” at the bottom pane.

clip_image024

 

There you have it.

We have created from scratch a Linux Environment, then installed NPM, then installed Azure XPLAT CLI. Finally used the CLI environment to connect to Azure and then create a resource – in this case a Linux VM.