remove OutFile and better LRO handling
This commit is contained in:
Родитель
87cabe501f
Коммит
cff9923a84
|
@ -19,3 +19,5 @@ _tools/*
|
||||||
Sample-*
|
Sample-*
|
||||||
|
|
||||||
/modules
|
/modules
|
||||||
|
|
||||||
|
/ADO-Pipeline
|
|
@ -129,7 +129,6 @@ Function Invoke-FabricAPIRequest {
|
||||||
[Parameter(Mandatory = $false)] $body,
|
[Parameter(Mandatory = $false)] $body,
|
||||||
[Parameter(Mandatory = $false)] [string] $contentType = "application/json; charset=utf-8",
|
[Parameter(Mandatory = $false)] [string] $contentType = "application/json; charset=utf-8",
|
||||||
[Parameter(Mandatory = $false)] [int] $timeoutSec = 240,
|
[Parameter(Mandatory = $false)] [int] $timeoutSec = 240,
|
||||||
[Parameter(Mandatory = $false)] [string] $outFile,
|
|
||||||
[Parameter(Mandatory = $false)] [int] $retryCount = 0
|
[Parameter(Mandatory = $false)] [int] $retryCount = 0
|
||||||
|
|
||||||
)
|
)
|
||||||
|
@ -149,7 +148,8 @@ Function Invoke-FabricAPIRequest {
|
||||||
|
|
||||||
Write-Verbose "Calling $requestUrl"
|
Write-Verbose "Calling $requestUrl"
|
||||||
|
|
||||||
$response = Invoke-WebRequest -Headers $fabricHeaders -Method $method -Uri $requestUrl -Body $body -TimeoutSec $timeoutSec -OutFile $outFile
|
# If need to use -OutFile beware of the following breaking change: https://github.com/PowerShell/PowerShell/issues/20744
|
||||||
|
$response = Invoke-WebRequest -Headers $fabricHeaders -Method $method -Uri $requestUrl -Body $body -TimeoutSec $timeoutSec
|
||||||
|
|
||||||
$lroFailOrNoResultFlag = $false
|
$lroFailOrNoResultFlag = $false
|
||||||
|
|
||||||
|
@ -172,15 +172,17 @@ Function Invoke-FabricAPIRequest {
|
||||||
|
|
||||||
if ($lroStatusContent.status -ieq "succeeded")
|
if ($lroStatusContent.status -ieq "succeeded")
|
||||||
{
|
{
|
||||||
try {
|
# Only calls /result if there is a location header, otherwise 'OperationHasNoResult' error is thrown
|
||||||
$response = Invoke-WebRequest -Headers $fabricHeaders -Method Get -Uri "$asyncUrl/result"
|
|
||||||
|
$resultUrl = [string]$response.Headers.Location
|
||||||
|
|
||||||
|
if ($resultUrl)
|
||||||
|
{
|
||||||
|
$response = Invoke-WebRequest -Headers $fabricHeaders -Method Get -Uri $resultUrl
|
||||||
}
|
}
|
||||||
catch {
|
else
|
||||||
$ex = $_.Exception
|
{
|
||||||
$lroFailOrNoResultFlag = $true
|
$lroFailOrNoResultFlag = $true
|
||||||
# Some APIs like UpdateDefinition throw a 'OperationHasNoResult' when there is no result.
|
|
||||||
# TODO: Try to find a better way to handle this error.
|
|
||||||
#Write-Host "Error calling /result API. $($ex.Message)"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -251,7 +253,7 @@ Function Invoke-FabricAPIRequest {
|
||||||
|
|
||||||
if ($retryCount -le $maxRetries)
|
if ($retryCount -le $maxRetries)
|
||||||
{
|
{
|
||||||
Invoke-FabricAPIRequest -authToken $authToken -uri $uri -method $method -body $body -contentType $contentType -timeoutSec $timeoutSec -outFile $outFile -retryCount ($retryCount + 1)
|
Invoke-FabricAPIRequest -authToken $authToken -uri $uri -method $method -body $body -contentType $contentType -timeoutSec $timeoutSec -retryCount ($retryCount + 1)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw "Exceeded the amount of retries ($maxRetries) after 429 error."
|
throw "Exceeded the amount of retries ($maxRetries) after 429 error."
|
||||||
|
|
Загрузка…
Ссылка в новой задаче