Azure cli on Mac

Posted in: Cloud, Technical Track

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
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

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
data: myoragate StoppedDeallocated East US
data: myoradb2 StoppedDeallocated East US
data: mypostgr01StoppedDeallocated East US
info: vm list command OK

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 ""
data: Location "East US"
data: VMName "oradb1"
data: IPAddress ""
data: InstanceStatus "RoleStateUnknown"
data: InstanceSize "Medium"
info: vm show command OK

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. 



Want to talk with an expert? Schedule a call with our team to get the conversation started.

About the Author

Regarded by his peers as an Oracle guru, Gleb is known for being able to resolve any problem related to Oracle. He loves the satisfaction of troubleshooting, and his colleagues even say that seeking Gleb’s advice regarding an issue is more efficient than looking it up. Gleb enjoys the variety of challenges he faces while working at Pythian, rather than working on the same thing every day. His areas of speciality include Oracle RAC, Exadata, RMAN, SQL tuning, high availability, storage, performance tuning, and many more. When he’s not working, running, or cycling, Gleb can be found reading.

No comments

Leave a Reply

Your email address will not be published. Required fields are marked *