Azure Powershell Cmdlets for 1.7, June 2012: What Happened to Get-OperationStatus?

The new Powershell cmdlets (documented here: http://msdn.microsoft.com/en-us/library/windowsazure/jj152841 ) look great, but there’s one that’s missing:

Get-OperationStatus -WaitToComplete

Without this, my Azure operations (e.g. Set-AzureDeployment) are not waiting for completion.

This makes it difficult to understand when, for example, an executable instance is executed before executing a VIP exchange.

Are there any alternatives?

+5
source share
2 answers

So, after research, my initial assumption was partly wrong: with the exception of calls for new Powershell cmdlets Set-AzureDeployment -newStatus "Running".

, Get-OperationStatus, script; , , Set-AzureDeployment .

Get-AzureDeployment, RoleInstanceList, , . :

function Get-StagingReady {
    $stagingStatus = Get-AzureDeployment $azureService -slot staging 
    if (-not $($stagingStatus.Status -eq "Running")) {
        Write-Host $(" ... ... Staging slot status is not Running; value is " + $stagingStatus.Running)
        return $False
    }

    if (-not $stagingStatus.RoleInstanceList) {
        Write-Host " ... ... Staging slot has no instances configured yet."
        return $False
    }

    $notReady = $False

    Foreach ($roleInstance in $stagingStatus.RoleInstanceList) {
        if (-not $($roleInstance.InstanceStatus -eq "ReadyRole")) {
            Write-Host $(" ... ... ... Staging slot instance " + $roleInstance.InstanceName + " has status " + $roleInstance.InstanceStatus)
            $notReady = $True
        }
    }

    if ($notReady) {
        Write-Host " ... ... One or more instances not running."
        return $False
    }

    Write-Host " ... Staging slot ready for use."
    return $True
}


function Wait-ForStagingToBeReady {
    while ( -not $(Get-StagingReady) ) {
        Write-Host " ... ... Staging slot not ready, waiting 15 seconds for Azure to spin up instances."
        Start-Sleep -s 15
    }
}


function Start-Staging {
    Write-Host " ... Starting staging slot."

    $staging = Get-Staging $azureService 
    $result = Set-AzureDeployment `
            -Status `
            -serviceName $azureService `
            -slot "Staging" `
            -newStatus "Running" 

    if (-not $?) {
        Write-Host
        Write-Host "Unable to start staging slot."
        Write-Host "DEPLOY FAILED"
        Write-Host
        exit 1
    }

    Wait-ForStagingToBeReady

    Write-Host " ... Deployment in Staging slot started."
}
+10

All Articles