0

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.

Joe.wang
  • 11,537
  • 25
  • 103
  • 180

2 Answers2

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.

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.

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • Thanks. I was thinking if there is any possibility of never break in the loop of the above script? – Joe.wang Jan 02 '14 at 09:04
  • Thanks your professional and informative update. In my script ,I want to know when the New-AzureDeployment was executed successfully. So I thought maybe I can use the spin query of deployment status to achieve it. But what if the deployment had something wrong happened. and the status remain `Suspend` status(for example) and never be changed. For this case ,What can I do to handle this kind of exception ? One of ways I can thought is using timeout validation in the spin query. – Joe.wang Jan 02 '14 at 09:34
  • But I want to know if there is a better way to make it , or maybe there is something about the condition of status changing I didn't know so far. So hope someone can get me out of there. thanks. – Joe.wang Jan 02 '14 at 09:39
  • 1
    Not 100% sure but I guess you would need to consider all possible statuses and take action according to status returned and not just `Running` status. – Gaurav Mantri Jan 02 '14 at 09:49
0

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

Sri Kanth
  • 476
  • 2
  • 14