Windows Azure Service Management API Cheat Sheet with PowerShell

I just wanted to share a little tweak added to the PowerShell cmdlets that made it quite a bit easier to troubleshoot them as they were being built.
If you are trying to understand the Service Management API for VMs it may be useful :)

For most of the cmdlets that have a significant request payload such as New-AzureVM etc.. We’ve added a -Verbose switch that will dump out the underlying API request as it is executed.

For example, this snippet creates a new Windows Server 2008 R2 VM with port 80 open and a data disk attached with ReadWrite caching enabled.

New-AzureVMConfig -Name 'myvm' -ImageName 'MSFT__Win2K8R2SP1-120514-1520-141205-01-en-us-30GB.vhd' -InstanceSize 'Small' |
	Add-AzureProvisioningConfig -Windows -Password 'somepassword' |
	Add-AzureEndpoint -Name 'web' -LocalPort 80 -PublicPort 80 -Protocol tcp |
	Add-AzureDataDisk -CreateNew -DiskSizeInGB 50 -DiskLabel 'CacheDisk' -HostCaching 'ReadWrite' -LUN 0 | 
	New-AzureVM -ServiceName 'myservicefromps' -Location 'East US' -Verbose

In the resulting output you can see that the New-AzureVM cmdlet actually makes two API calls in order to create the hosted service and then the new deployment. If you omit the -location parameter it will attempt to use an existing cloud service.

[sourcecode language="XML"]
VERBOSE: <CreateHostedService xmlns:i="" xmlns="">
<Description>Implicitly created hosted service2012-06-11 09:11</Description>
<Location>East US</Location>

New-AzureVM – Create Cloud Service 68f6b264-c97a-4e85-84f0-6f554494a0e0 Succeeded

VERBOSE: <Deployment xmlns:i="" xmlns="">
<Role i:type="PersistentVMRole">
<OsVersion i:nil="true" />
<ConfigurationSet i:type="WindowsProvisioningConfigurationSet">
<ConfigurationSet i:type="NetworkConfigurationSet">
New-AzureVM – Create Deployment with VM myvm d0e4c5d5-9c51-422d-abfa-6e856639272c Succeeded

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>