Alongside the introduction of Windows Azure Web Sites and exciting new Virtual Machine capabilities, we recently released a set of open source command line tools that allow you to manage and deploy these new services from the command line on any operating system, including for the first time Apple OS X and Linux.
In this post I’m going to walk you through the installation and basic use of the tool, as well as share information on how you can learn more and even contribute to the tool (it is open source Node.js code, licensed under the Apache 2.0 license, hosted on github.com, and my team accepts contributions).
To get started, you need to download and install the cross-platform command line tools. Depending on your operating system, there are several options.
You can find the tool download on any of the “develop” pages of the Windows Azure Web Site, but I usually start on the Node.js develop page.
Installing on Your Mac
We’ve prepared a nice Mac installer experience, so if you download the Mac installer, you just walk through the standard wizard.
At the end of the setup, the ‘azure’ command will be available in the Terminal application. The command is located in /usr/local/bin/.
You can uninstall the tools at any time by typing ‘azure-uninstall’ and follow the instructions.
Installing using NPM
Alternatively, if you have Node.js installed on your machine already, you can actually quickly install the command line tools.
We actually implemented the tool in Node.js and the tool can be installed as part of our npm module for Windows Azure. Npm is the recommended install method if you’d like to use the command line interface on Linux or Windows.
npm install azure –global
Command Line Syntax
Once you’ve installed the command line interface (CLI) for Windows Azure, you just type ‘azure’ from your terminal application.
If you just type ‘azure’ you will get a list of the available high-level commands that we support such as ‘site’, ‘vm’, ‘account’, etc.
Side note: Yes, that’s some awesome UX-approved ASCII art.
You can then drill down into the sub sections and verbs that are available; for example, type ‘azure site’ to see how you can work with a Web Site:
As part of using the tool, you’ll want to initially set the tool up to use your Windows Azure subscription and account information.
Enabling Preview Features
Because the new VM capabilities and Web Sites feature are “preview” as of the writing of this post, you need to enable these preview capabilities.
To do this, you go to http://account.windowsazure.com/ and click on the ‘preview features’ heading, opting in to both Web Sites and Virtual Machines. You can find more information in the quick Node.js web site tutorial.
Preparing a Publishing Profile and Credentials
Once you are set up with the preview features, you do need to go to the http://manage.windowsazure.com/ site to create a publishing profile where you set up Git publishing credentials.
This just has to be done the first time: after doing this once, you can party in the command line all you like without having to go back to the management portal online.
The step-by-step instructions are available in how complete guide about using the command line tools, but a summary of what needs to be done:
Run ‘azure account download’ to open the browser to a page where you can sign in and download the publish settings file. This is a temporary file with credentials that you will store on your machine.
After downloading the file, use ‘azure account import <path to the publishsettings file>’ to grab those credentials in a way that the tool can ingest.
Next, delete the .publishsettings file.
You’re now setup to publish to your account and Windows Azure subscription with the preview features.
Creating, Deploying and Managing a Web Site
To use the new Web Sites feature, you can use the ‘azure site’ section of the CLI.
To Create a new Web Site
You can either type ‘azure site create’ (this will walk you through the various options) or ‘azure site create NameOfYourSite –git’ which will prepare a new site and even set up a Git repository locally for publishing.
When you move in to the folder created, you can then use Git to publish, as well as ‘azure site browse’ to open the actual live site in your web browser.
To Maintain Your Web Sites
You can see the list of sites you have on your account by typing ‘azure site list’; other functions include delete, stop, and start.
More information on Web Sites and the Command Line Tool
For more information on this, please check out:
Working with Virtual Machines
There are multiple ways to work with virtual machines (VMs) in Windows Azure: you can either go ahead and provide a virtual machine image (a .vhd file) to get one going, or much easier, you can use the ‘Image Gallery’ to actually spin up an available, pre-created image.
I prefer using the images as I’m often working with CentOS images for my Linux deployment work.
We have some great partners that have provided helpful images to get you going. To see a list of currently available virtual machine images for your account, use the ‘azure vm image list’ command.
You can then use the image of your choice to get started. For example, to create a CentOS image, here’s an example command line:
azure vm create myVM OpenLogic__OpenLogic-CentOS-62-20120509-en-us-30GB.vhd myusername –location “West US”
You should probably also provide either –ssh (Linux) or –rdp (Windows) so that you can later connect to the machines remotely to administer them.
Once you create a site, you can also prepare endpoints for network connectivity (see ‘azure vm endpoint’) or perform other administrative operations (azure vm show, azure vm shutdown, azure vm start, azure vm restart, or even azure vm delete).
For a complete list of commands, type azure vm –h.
Exploring and Contributing to the Open Source Code
The open source code to all of the Windows Azure SDK can be found on GitHub.
All of our code is licensed under the Apache 2.0 license and we do accept code contributions.
- You can find the source to the cross-platform command line tool here and guidelines for contributing are located here.
- Feel free to open issues on the tool as a GitHub issue
We hope that you find this new tool very helpful and look forward to your feedback and code contributions.
- By Jeff Wilcox, Development Lead, Windows Azure SDK