Question

All, I am trying to deploy my cloud service to Windows Azure. Currently It works fine. But I still try to understand the detail inside of it . Like below Power Shell script. The script is trying to get the status of a deplpoyment in the Staging slot after New-AzureDeployment has been executed successfully.

while ($True) {
    $deployment = Get-AzureDeployment -ServiceName $CloudServiceName -Slot Staging
    if ($deployment.Status -ne 'Running') {
        continue
    }
    $notReadyList = $deployment.RoleInstanceList | Where-Object InstanceStatus -ne 'ReadyRole'
    if (!$notReadyList) {
        break
    }

    $errorStatusList = @('RestartingRole';'CyclingRole';'FailedStartingRole';'FailedStartingVM';'UnresponsiveRole')
        $errorList = $notReadyList | Where-Object InstanceStatus -in $errorStatusList
    if ($errorList) {
        throw 'Role in staging fail to start for some of these reasons:' + ($errorList | Format-List | Out-String)
    }

    Start-Sleep -Seconds 10
}

I have some questions about the script . Please try to help me .thanks.

  1. What is the object type of Get-AzureDeployment return ? I search it in the Help Doc. But did't found any information about it.

  2. How many possible status except Running the Get-AzureDeployment could return ?

  3. Is there any possibility never break in the loop ?

Thanks.

Was it helpful?

Solution

What is the object type of Get-AzureDeployment return ? I search it in the Help Doc. But did't found any information about it.

As mentioned in the documentation, this operation returns an object of type DeploymentInfoContext. You can find more about this object here: https://github.com/WindowsAzure/azure-sdk-tools/blob/master/WindowsAzurePowershell/src/Commands.ServiceManagement/Model/DeploymentInfoContext.cs. However if you look at the source code for Get-AzureDeployment here: https://github.com/WindowsAzure/azure-sdk-tools/blob/master/WindowsAzurePowershell/src/Commands.ServiceManagement/HostedServices/GetAzureDeployment.cs, you'll notice that it returns the following:

return new DeploymentInfoContext(d)
                    {
                        OperationId = s.Id,
                        OperationStatus = s.Status.ToString(),
                        OperationDescription = CommandRuntime.ToString(),
                        ServiceName = this.ServiceName
                    };

How many possible status except Running the Get-AzureDeployment could return ?

You can find the list of possible statuses here: http://msdn.microsoft.com/en-us/library/windowsazure/ee460804.aspx.

Following is copied from the link above:

enter image description here

Is there any possibility never break in the loop ?

I'm not sure about that. I guess you will need to test it out thoroughly. The statuses may change with the newer versions of Service Management API so you would need to ensure that your code covers all possible statuses.

OTHER TIPS

Get-AzureDeployment returns an object of schema shown below

SdkVersion :
RollbackAllowed : False
Slot : Production
Name :
DeploymentName : [Somename]
Url : http://[Somename].cloudapp.net/
Status : Suspended
CurrentUpgradeDomain : 0
CurrentUpgradeDomainState :
UpgradeType :
RoleInstanceList : {}
Configuration :
DeploymentId : [SomeGUID]
Label : [Somename]
VNetName : [Somename]
DnsSettings :
OSVersion :
RolesConfiguration : {[[Somename], Microsoft.WindowsAzure.Commands.ServiceManagement.Model.RoleConfiguration]}
ServiceName : [Somename]
OperationDescription : Get-AzureDeployment OperationId : 1801bce8-73b4-5a74-9e80-e03d04ff405b OperationStatus : Succeeded

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top