Once deployed, an application needs instrumentation, diagnostics and an easy way to perform administrative tasks that apply to it. So far, we’ve only had the Azure Web Portal to deploy, move from staging to production or back, retrieve application configuration or deployment status,which works, but an automated solution could be the trick you need.
Cmdlets are lightweight PowerShell commands that you can use to automate just about any task you have. You can simply use Cmdlets or author your own. Here we’ll look at a few things that Windows Azure Service Management (WASM) Cmdlets can do to automate your Azure management tasks. The Cmdlets referenced here use the same Azure Management Service API that’s available for .NET developers.
Before we get into running Cmdlets specifically for Azure management, we’ll take a quick look at how to use Cmdlets in general. To start, you don’t need to be a PowerShell expert to use Cmdlets. Once you’ve installed the Cmdlets you want to work with, you can call them much like any other code you’ve written. You pass parameters/attributes or switches to the Cmdlets and they return .NET framework objects that you can work with, so they behave much like you’re writing functions in a command window of an IDE.
To start, open PowerShell (See Getting Started: Cmdlet Installation below to verify PowerShell is installed and ready). You can then see a listing of all PowerShell commands by typing:
and pressing enter. You’ll see a listing of all PowerShell commands and Cmdlets that are installed along with their respective command type. You’ll notice many are the same or similar to DOS commands.
To use a CmdLet, you’ll just enter the Cmdlet name and pass any parameters and/or switches to it that it requires. It will display output or allow you to set a variable and return the result to that variable. For example, if I wanted to see help about a particular Cmdlet, I use the following syntax: get-help <Cmdlet name> (where Cmdlet name is the parameter) as shown below:
In this example, the get-help Cmdlet will display the parameters needed to call the get-service Cmdlet. The get-service Cmdlet displays all the services on the local or a remote machine. That’s all to it. Once you know what parameters and/or switches are required by using get-help, you then have all the information to run the Cmdlet you want. Now we can move onto using Cmdlets to manage our Azure instances.
WASM Cmdlets help you automate Azure management tasks more effectively by allowing you to run commands and build batches of common administrative tasks. Here’s the types of commands you can run with Azure Cmdlets: