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.
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
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.
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).
Install Azure CLI
Next step is to install the Azure CLI after Node.js has been installed.
sudo npm install –g azure-cli
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.
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>”
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
Setting your Azure Account
Then download your account – the command is shown below.
“azure account download”
I was not able to download it, hence I went to the URL above (in yellow) and directly downloaded it from the browser.
Then you will have your publishsettings file in the “Downloads” folder as shown below which you then import.
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.
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
Now login to the Azure portal. You will be able to see the VM being provisioned OR fully created.
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.
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.