Skip to content

Commit fed4538

Browse files
authored
Merge and squash from wayan to wayan-pr (#1)
* 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
1 parent a71bfac commit fed4538

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/SdkClient/ResourceManagerSdkClient.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ private DeploymentExtended WaitDeploymentStatus(
314314
{
315315
DeploymentExtended deployment;
316316

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

338-
deployment = ResourceManagementClient.Deployments.Get(resourceGroup, deploymentName);
339-
340-
step = phaseOne > 0 ? 5 : 60;
341-
339+
using (var getResult = ResourceManagementClient.Deployments.GetWithHttpMessagesAsync(resourceGroup, deploymentName).ConfigureAwait(false).GetAwaiter().GetResult())
340+
{
341+
deployment = getResult.Body;
342+
if (getResult.Response.Headers.RetryAfter != null && getResult.Response.Headers.RetryAfter.Delta.HasValue)
343+
{
344+
step = getResult.Response.Headers.RetryAfter.Delta.Value.Seconds;
345+
}
346+
else
347+
{
348+
step = phaseOne > 0 ? 5 : 60;
349+
}
350+
}
342351
} while (!status.Any(s => s.ToString().Equals(deployment.Properties.ProvisioningState, StringComparison.OrdinalIgnoreCase)));
343352

344353
return deployment;
@@ -549,7 +558,7 @@ public virtual PSResourceGroup CreatePSResourceGroup(PSCreateResourceGroupParame
549558
},
550559
() => resourceExists);
551560

552-
return resourceGroup != null? resourceGroup.ToPSResourceGroup() : null;
561+
return resourceGroup != null ? resourceGroup.ToPSResourceGroup() : null;
553562
}
554563

555564
/// <summary>

0 commit comments

Comments
 (0)