Search Wiki:

Project Description

A set of PowerShell cmdlets wrapping the Windows Azure Service Management API. These cmdlets make is simple to script out your deployments, upgrades, and scaling of your Windows Azure applications.

cmdlets.png

Supported Operations


The Windows Azure Service Management CmdLets support the following operations:

Affinity Group Operations

  • Get-AffinityGroup
  • Get-AffinityGroups

Service Operations

  • Get-Certificate
  • Get-Certificates
  • Get-HostedProperties
  • Get-HostedService
  • Get-HostedServices

Service Upgrade and Deployment Operations

  • Add-Certificate
  • Get-Deployment
  • Move-Deployment
  • New-Deployment
  • Remove-Certificate
  • Remove-Deployment
  • Set-Deployment
  • Set-DeploymentConfiguration
  • Set-DeploymentStatus
  • Set-WalkUpgradeDomain

Status Operations

  • Get-OperationStatus

Storage Service Operations

  • Get-StorageKeys
  • Get-StorageProperties
  • Get-StorageServices
  • New-StorageKey

For more information on the Service Management API, please consult the MSDN documentation

Example Uses

The following script gets an existing deployment, shuts it down, deletes it, creates a new one in it's place, starts it, and then scales the 'WebUx' role by 1 instance.

$cert = Get-Item cert:\CurrentUser\My\D6BE55AC439FEA8CBEBAFF432BDC0780F1BD00CF
$sub = "CCCEA07B-1E9A-5133-8476-3818E2165063"
$servicename = 'myazureservice'
$package = "c:\publish\MyAzureService.cspkg"
$config = "c:\publish\ServiceConfiguration.cscfg"
 
Add-PSSnapin AzureManagementToolsSnapIn
 
Get-HostedService $servicename -Certificate $cert -SubscriptionId $sub |
    Get-Deployment -Slot Production |
    Set-DeploymentStatus 'Suspended' |
    Get-OperationStatus -WaitToComplete |
 
Get-HostedService $servicename -Certificate $cert -SubscriptionId $sub | 
    Get-Deployment -Slot Production | 
    Remove-Deployment | 
    Get-OperationStatus -WaitToComplete
    
Get-HostedService $servicename -Certificate $cert -SubscriptionId $sub |
    New-Deployment Production $package $config -Label 'v.Next' | 
    Get-OperationStatus -WaitToComplete
    
Get-HostedService $servicename -Certificate $cert -SubscriptionId $sub | 
    Get-Deployment -Slot Production | 
    Set-DeploymentStatus 'Running' | 
    Get-OperationStatus -WaitToComplete
    
Get-HostedService $servicename -Certificate $cert -SubscriptionId $sub |
    Get-Deployment -Slot Production |
    Set-DeploymentConfiguration {$_.RolesConfiguration["WebUx"].InstanceCount += 1}

A simple script to upgrade a single role or the entire deployment:

$cert = Get-Item cert:\CurrentUser\My\D6BE55AC439FEA8CBEBAFF432BDC0780F1BD00CF
$sub = "CCCEA07B-1E9A-5133-8476-3818E2165063"
$servicename = 'myservice'
$package = "http://myaccount.blob.core.windows.net/publish/MyPackage.cspkg"
 
$label = 'nolabel'
$role = ''
 
if ($args.Length -eq 2)
{
    $role = $args[0]
    $label = $args[1]
}
 
if ($args.Length -eq 1)
{
    $label = $args[0]
}
 
if ($role -ne '')
{
    Get-HostedService $servicename -Certificate $cert -SubscriptionId $sub |
    Get-Deployment -Slot Production | 
    Set-Deployment -mode Auto -roleName $role -package $package -label $label |
    Get-OperationStatus -WaitToComplete
}
else
{
    Get-HostedService $servicename -Certificate $cert -SubscriptionId $sub |
    Get-Deployment -Slot Production | 
    Set-Deployment -mode Auto -package $package -label $label |
    Get-OperationStatus -WaitToComplete
}

Please note that during the free CTP, you will only be able to scale your services to 2 instances per role.
Last edited Nov 17 2009 at 10:18 PM  by dunnry, version 8
Comments
spruce wrote  Jan 27 at 2:23 AM  
I'm getting errors "HTTP Status Code: ResourceNotFound - HTTP Error Message: The specified resource does not exist. Details: No deployments found" when I try running the sample script with my configuration. How can I troubleshoot?

$cert = Get-Item cert:\CurrentUser\Root\XXXX
$sub = XXX
$servicename = 'myproject'
$package = "F:\Publish\MyProject.cspkg"
$config = "F:\Publish\ServiceConfiguration.cscfg"

Get-HostedService $servicename -Certificate $cert -SubscriptionId $sub |
Get-Deployment -Slot Production |
Set-DeploymentStatus 'Suspended' |
Get-OperationStatus -WaitToComplete |

Get-HostedService $servicename -Certificate $cert -SubscriptionId $sub |
Get-Deployment -Slot Production |
Remove-Deployment |
Get-OperationStatus -WaitToComplete

Get-HostedService $servicename -Certificate $cert -SubscriptionId $sub |
New-Deployment Production $package $config -Label 'v.Next' |
Get-OperationStatus -WaitToComplete

Get-HostedService $servicename -Certificate $cert -SubscriptionId $sub |
Get-Deployment -Slot Production |
Set-DeploymentStatus 'Running' |
Get-OperationStatus -WaitToComplete

Updating...
Page view tracker