added exponential backoff to ARM deployments

This commit is contained in:
Jorge Cotillo 2019-11-22 10:52:51 -08:00
Родитель 0fe1cf717b
Коммит 1d23426e2b
3 изменённых файлов: 11 добавлений и 12 удалений

Просмотреть файл

@ -10,7 +10,7 @@
},
"Cache": {
"Comments": "Caching service",
"StorageType": "AzureDevOps"
"StorageType": "Local"
},
"ValidationResourceGroup": {
"Name": "vdc-custom-rg",

Просмотреть файл

@ -423,7 +423,7 @@ Function Start-ExponentialBackoff () {
-ScriptBlock $Expression `
-ArgumentList $Arguments;
}
catch [System.Threading.Tasks.TaskCanceledException] {
catch {
$newWait = ($i * 60);
Write-Debug "Sleeping for: $newWait seconds";
Start-Sleep -Seconds ($i * 60);
@ -432,10 +432,6 @@ Function Start-ExponentialBackoff () {
$innerException = Get-Exception -ErrorObject $_;
}
}
catch {
Throw `
$(Get-Exception -ErrorObject $_);
}
}
throw "Maximum number of retries reached. Number of retries: $MaxRetries. InnerException: $innerException";

Просмотреть файл

@ -186,12 +186,15 @@ Class AzureResourceManagerDeploymentService: IDeploymentService {
# Call REST API to start the deployment
$deployment = `
Invoke-RestMethod `
-Method $method `
-Uri $uri `
-Body $requestBody `
-Headers $headers `
-ContentType "application/json";
Start-ExponentialBackoff `
-Expression { `
Invoke-RestMethod `
-Method $method `
-Uri $uri `
-Body $requestBody `
-Headers $headers `
-ContentType "application/json"; }
Write-Debug "Result of ARM Invocation is: $(ConvertTo-Json $deployment -Depth 50)";