Skip to content

Commit

Permalink
Merge and squash from wayan to wayan-pr (#1)
Browse files Browse the repository at this point in the history
* Added RetryAfter support for New-AzureRmResourceGroupDeployment

* Revert "Added RetryAfter support for New-AzureRmResourceGroupDeployment"

This reverts commit ccf9ded.

* Redo the change using methods within the SDK

* Updated comments
  • Loading branch information
luanshixia authored Feb 22, 2017
1 parent a71bfac commit fed4538
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ private DeploymentExtended WaitDeploymentStatus(
{
DeploymentExtended deployment;

// Poll deployment state and deployment operations with two phases. In phase one, poll every 5 seconds. Phase one
// Poll deployment state and deployment operations after RetryAfter.
// If no RetryAfter provided: In phase one, poll every 5 seconds. Phase one
// takes 400 seconds. In phase two, poll every 60 seconds.
const int counterUnit = 1000;
int step = 5;
Expand All @@ -335,10 +336,18 @@ private DeploymentExtended WaitDeploymentStatus(
job(resourceGroup, deploymentName, basicDeployment);
}

deployment = ResourceManagementClient.Deployments.Get(resourceGroup, deploymentName);

step = phaseOne > 0 ? 5 : 60;

using (var getResult = ResourceManagementClient.Deployments.GetWithHttpMessagesAsync(resourceGroup, deploymentName).ConfigureAwait(false).GetAwaiter().GetResult())
{
deployment = getResult.Body;
if (getResult.Response.Headers.RetryAfter != null && getResult.Response.Headers.RetryAfter.Delta.HasValue)
{
step = getResult.Response.Headers.RetryAfter.Delta.Value.Seconds;
}
else
{
step = phaseOne > 0 ? 5 : 60;
}
}
} while (!status.Any(s => s.ToString().Equals(deployment.Properties.ProvisioningState, StringComparison.OrdinalIgnoreCase)));

return deployment;
Expand Down Expand Up @@ -549,7 +558,7 @@ public virtual PSResourceGroup CreatePSResourceGroup(PSCreateResourceGroupParame
},
() => resourceExists);

return resourceGroup != null? resourceGroup.ToPSResourceGroup() : null;
return resourceGroup != null ? resourceGroup.ToPSResourceGroup() : null;
}

/// <summary>
Expand Down

0 comments on commit fed4538

Please sign in to comment.