Introducing Microsoft’s OFFICIAL Windows Azure PowerShell Module!

Hello folks! Today, Microsoft has officially announced the availability of a new PowerShell module to help manage Windows Azure features! In order to obtain this module, you will need to download the Web Platform Installer 4.0 (x64, x86). Once you’ve installed the Web Platform Installer 4.0, you’ll need to search for “PowerShell” and install the “Windows Azure PowerShell” package from it.

Web Platform Installer 4.0 - Azure PowerShell Screenshot

Once the Windows Azure PowerShell package has been installed via the WPI, you can launch it by finding the “Windows Azure PowerShell” shortcut in the Start Menu. Alternatively, if you examine the path that the shortcut is pointing to, it’s simply calling this piece of code to import the module. You can run this inside of any PowerShell session, and it ought to work.

[cc]cd ‘C:\’; Get-ChildItem ‘C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\*.psd1’ | ForEach-Object {Import-Module $_}[/cc]

Note: Don’t look for the module files in your user profile’s module path, or in the system’s module path; you won’t find them there!

Now that you’ve got the Azure module imported into your PowerShell session, we can start to explore the commands available to us. By now, you’re probably already familiar with the [cci]Get-Command[/cci] cmdlet, which has a handy-dandy [cci]-Module[/cci] parameter, which can be used to filter for commands from the module.

But wait just one second! What is the name of the module? Is it [cci]Azure[/cci], or [cci]AzurePowerShell[/cci], or something else similar? Let’s find out by using the [cci]Get-Module[/cci] cmdlet!

[cc]
ModuleType Name ExportedCommands
———- —- —————-
Manifest Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content…}
Manifest Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object…}
Binary Microsoft.WindowsAzure.Management {Add-AzureCertificate, Add-AzureDataDisk, Add-AzureDisk, Add-AzureEnd…
[/cc]

Aha — there it is! The name is [cci]Microsoft.WindowsAzure.Management[/cci]. So with that in mind, we can run the command:

[cc]Get-Command -Module Microsoft.WindowsAzure.Management;[/cc]

Look at all the data we get back with that!

[cc]
CommandType Name
———– —-
Cmdlet Add-AzureCertificate
Cmdlet Add-AzureDataDisk
Cmdlet Add-AzureDisk
Cmdlet Add-AzureEndpoint
Cmdlet Add-AzureNodeWebRole
Cmdlet Add-AzureNodeWorkerRole
Cmdlet Add-AzurePHPWebRole
Cmdlet Add-AzurePHPWorkerRole
Cmdlet Add-AzureProvisioningConfig
Cmdlet Add-AzureVMImage
Cmdlet Disable-AzureServiceProjectRemoteDesktop
Cmdlet Enable-AzureServiceProjectRemoteDesktop
Cmdlet Export-AzureVM
Cmdlet Get-AzureAffinityGroup
Cmdlet Get-AzureCertificate
Cmdlet Get-AzureDataDisk
Cmdlet Get-AzureDeployment
Cmdlet Get-AzureDisk
Cmdlet Get-AzureDns
Cmdlet Get-AzureEndpoint
Cmdlet Get-AzureLocation
Cmdlet Get-AzureOSDisk
Cmdlet Get-AzureOSVersion
Cmdlet Get-AzurePublishSettingsFile
Cmdlet Get-AzureRemoteDesktopFile
Cmdlet Get-AzureRole
Cmdlet Get-AzureService
Cmdlet Get-AzureStorageAccount
Cmdlet Get-AzureStorageKey
Cmdlet Get-AzureSubnet
Cmdlet Get-AzureSubscription
Cmdlet Get-AzureVM
Cmdlet Get-AzureVMImage
Cmdlet Get-AzureVNetConfig
Cmdlet Get-AzureVNetConnection
Cmdlet Get-AzureVNetGateway
Cmdlet Get-AzureVNetGatewayKey
Cmdlet Get-AzureVNetSite
Cmdlet Import-AzurePublishSettingsFile
Cmdlet Import-AzureVM
Cmdlet Move-AzureDeployment
Cmdlet New-AzureAffinityGroup
Cmdlet New-AzureCertificateSetting
Cmdlet New-AzureDeployment
Cmdlet New-AzureDns
Cmdlet New-AzureQuickVM
Cmdlet New-AzureService
Cmdlet New-AzureServiceProject
Cmdlet New-AzureSSHKey
Cmdlet New-AzureStorageAccount
Cmdlet New-AzureStorageKey
Cmdlet New-AzureVM
Cmdlet New-AzureVMConfig
Cmdlet New-AzureVNetGateway
Cmdlet Publish-AzureServiceProject
Cmdlet Remove-AzureAffinityGroup
Cmdlet Remove-AzureCertificate
Cmdlet Remove-AzureDataDisk
Cmdlet Remove-AzureDeployment
Cmdlet Remove-AzureDisk
Cmdlet Remove-AzureEndpoint
Cmdlet Remove-AzureService
Cmdlet Remove-AzureStorageAccount
Cmdlet Remove-AzureSubscription
Cmdlet Remove-AzureVM
Cmdlet Remove-AzureVMImage
Cmdlet Remove-AzureVNetConfig
Cmdlet Remove-AzureVNetGateway
Cmdlet Reset-AzureRoleInstance
Cmdlet Restart-AzureVM
Cmdlet Save-AzureVMImage
Cmdlet Select-AzureSubscription
Cmdlet Set-AzureAffinityGroup
Cmdlet Set-AzureDataDisk
Cmdlet Set-AzureDeployment
Cmdlet Set-AzureEndpoint
Cmdlet Set-AzureOSDisk
Cmdlet Set-AzureRole
Cmdlet Set-AzureService
Cmdlet Set-AzureServiceProject
Cmdlet Set-AzureServiceProjectRole
Cmdlet Set-AzureStorageAccount
Cmdlet Set-AzureSubnet
Cmdlet Set-AzureSubscription
Cmdlet Set-AzureVMSize
Cmdlet Set-AzureVNetConfig
Cmdlet Set-AzureVNetGateway
Cmdlet Set-AzureWalkUpgradeDomain
Cmdlet Start-AzureEmulator
Cmdlet Start-AzureService
Cmdlet Start-AzureVM
Cmdlet Stop-AzureEmulator
Cmdlet Stop-AzureService
Cmdlet Stop-AzureVM
Cmdlet Test-AzureName
Cmdlet Update-AzureDisk
Cmdlet Update-AzureVM
Cmdlet Update-AzureVMImage[/cc]

Wow! How many commands do you think there are in the Azure module? Plug this into your console:

[cc](Get-Command -Module Microsoft.WindowsAzure.Management).count[/cc]

The first thing we’ll want to do is set up our Windows Azure subscriptions. To do that, we’ll use the [cci]Set-AzureSubscription[/cci] cmdlet. Once we’ve specified the subscription details, then we’re ready to start issuing commands! Let’s try just grabbing a list of our hosted service objects.

[cc]
# Register the subscription and its management certificate
Set-AzureSubscription `
-SubscriptionId 12345-12345-12345 `
-Certificate (gci cert:\currentuser\my\CERTTHUMBPRINT) `
-SubscriptionName FriendlyNameGoesHere

# Get a list of hosted services!
Get-AzureService;
[/cc]

After running the above command, you should get a bunch of objects returned to the pipeline, which represent Azure hosted service!

We’ve got lots more exploring to do, so keep these built-in PowerShell commands close at hand:

[cc]
Get-Help
Get-Command
Get-Member
Select-Object
[/cc]

Until next time … enjoy managing the cloud!