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.

1
cd 'C:\'; Get-ChildItem 'C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\*.psd1' | ForEach-Object {Import-Module $_}

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 Get-Command cmdlet, which has a handy-dandy -Module 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 Azure, or AzurePowerShell, or something else similar? Let’s find out by using the Get-Module cmdlet!

1
2
3
4
5
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...

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

1
Get-Command -Module Microsoft.WindowsAzure.Management;

Look at all the data we get back with that!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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

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

1
(Get-Command -Module Microsoft.WindowsAzure.Management).count

The first thing we’ll want to do is set up our Windows Azure subscriptions. To do that, we’ll use the Set-AzureSubscription 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.

1
2
3
4
5
6
7
8
# 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;

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:

1
2
3
4
Get-Help
Get-Command
Get-Member
Select-Object

Until next time … enjoy managing the cloud!

  • http://twitter.com/monkeyonahill/status/210834261882830848/ James Tryand (@monkeyonahill)

    @DanTup do the powershell commandlets work? http://t.co/4Jn8Hf9y

  • http://twitter.com/pcgeek86/status/211094584049139713/ (@pcgeek86) (@pcgeek86)

    Introducing #Microsoft’s official Windows #Azure #PowerShell module! #WindowsAzure #cloud http://t.co/H6Zdb1Ky

  • http://twitter.com/pcgeek86/status/211118702387662848/ (@pcgeek86) (@pcgeek86)

    Download the official #Microsoft Windows #Azure #PowerShell module! http://t.co/PifmDOGd #cloud #WindowsAzure http://t.co/H6Zdb1Ky

  • http://twitter.com/cantorjf/status/211164201257934850/ Lucio Riccardi (@cantorjf)

    “Introducing Microsoft’s OFFICIAL Windows Azure PowerShell Module!” http://t.co/nWaKOXbN

  • http://twitter.com/pcgeek86/status/212223539145736192/ (@pcgeek86) (@pcgeek86)

    Introducing #Microsoft’s official #WindowsAzure #PowerShell module! http://t.co/H6Zdb1Ky #azure #cloud

  • http://twitter.com/MaxTrinidad/status/212257388579913728/ Max Trinidad (@MaxTrinidad)

    Things couldn’t get better… “Introducing Microsoft’s OFFICIAL Windows #Azure #PowerShell Module” – baby steps: http://t.co/OIVZoBa0

  • http://twitter.com/nitinsalgar/status/213019948728061952/ Nitin Chandra Salgar (@nitinsalgar)

    New Azure Commandlets via @pcgeek86 http://t.co/8YAMkuhg

  • Pingback: PowerShell: Updating an Azure Service Display Name | Trevor Sullivan's Tech Room