Pythian Blog: Technical Track

Azure cli on Mac

Microsoft Azure has a really good, intuitive GUI interface where you can do a variety of tasks. But for me, as a DBA working most of my time in command line, sometimes it's much easier to log on and run command from my shell to start, stop or check the status for my VM. I am using a Macbook as my main work machine and luckily Microsoft provides Azure cli package for Mac. It's easy to set it up and start using. In this blog I will try to describe how to set it up and begin using a Mac. First, you need to download the azure-cli.0.9.8.dmg package and install it. It's a pretty easy and straight forward process. By the end of installation you will be redirected to an explanation from Ralph Squillace on the cli, which is definitely worth reading. Also, on the final screen of your installation you will see some useful advice like "how to start", "uninstall azure cli" and what you need to add to your "$PATH variable". By default it is going to be installed to your /usr/local/bin directory, so, it makes perfect sense to include it to your default PATH if you haven't done it before. I found the tool be pretty easy and straightforward to use. Now, go to your terminal window and type Azure. This will provide a perfect starting point with a list of available commands. You will need to login if you have a school or working account or alternatively download the publish settings if, like me, you have your own individual account for Azure. To do that just type command "azure account download". It will connect to the Microsoft portal and download the file you will need to import. Here are the commands and expected output: Glebs-MacBook:~ $ azure account download info: Executing command account download info: Launching browser to https://go.microsoft.com/fwlink/?LinkId=888832 help: Save the downloaded file, then execute the command help: account import info: account download command OK Glebs-MacBook:~ $ Glebs-MacBook:~ $ azure account import ~/Downloads/Pay-As-You-Go-8-27-2015-credentials.publishsettings info: Executing command account import info: account import command OK Glebs-MacBook:~ $ Now you can see your account: Glebs-MacBook:~$ azure account list info: Executing command account list data: Name Id Tenant Id Current data: ------------- ------------------------------------ --------- ------- data: Pay-As-You-Go 839567e2-ffb5-67f1-9e07-02547bd7e0a7 undefined true info: account list command OK Glebs-MacBook:~$ So, now you are all set and can use the tool with your own subscription. You don't need to import it again and will be able to use it just typing commands. Here I am going to show basic commands and output. To list your VMs just type: Glebs-MacBook:~$ azure vm list info: Executing command vm list + Getting virtual machines data: Name Status Location DNS Name IP Address data: -------- ------------------ -------- --------------------- ---------- data: myoradb1 StoppedDeallocated East US myoradb1.cloudapp.net data: myoragate StoppedDeallocated East US myoragate.cloudapp.net data: myoradb2 StoppedDeallocated East US myoradb2.cloudapp.net data: mypostgr01StoppedDeallocated East US mypostgr01.cloudapp.net info: vm list command OK Glebs-MacBook:~$ To start any of your machine run: Glebs-MacBook:~$ azure vm start myoradb1 info: Executing command vm start + Getting virtual machines + Starting VM info: vm start command OK Glebs-MacBook:~ otochkin$ azure vm show myoradb1 info: Executing command vm show + Getting virtual machines data: DNSName "myoradb1.cloudapp.net" data: Location "East US" data: VMName "oradb1" data: IPAddress "10.0.0.10" data: InstanceStatus "RoleStateUnknown" data: InstanceSize "Medium" ....................... info: vm show command OK Glebs-MacBook:~$ To get the help just run "azure -h" and it will provide list of main commands. After that you can run one of the commands without parameters like "azure vm" and it will give full list of available commands for the "vm" mode. That is it for now. Good luck in your exploration of Azure.   Discover more about our expertise with Cloud technologies.

No Comments Yet

Let us know what you think

Subscribe by email