You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And this is being called by an Orchestrator function:
param($Context)
Write-Output "Starting Orchestrator."
$RetryOptions = New-DurableRetryOptions -FirstRetryInterval (New-TimeSpan -Seconds 5) -MaxNumberOfAttempts 3
Write-Output "Retrieving Config Items from Autotask"
$APIData = Invoke-DurableActivity -FunctionName "Func-RetrieveAPIData" -RetryOptions $RetryOptions
# Build object (add metadata) to send to data lake
$SendObject = @{
APIData = $APIData
sourceName = "API"
}
# Convert to JSON to prep for sending
$SendJson = $SendObject | ConvertTo-Json -Depth 100
# Send to the data lake function
Write-Output "Sending Data to Data Lake function"
Invoke-DurableActivity -FunctionName "Func-SendtoDataLake" -Input $SendJson
When I look at Log Stream in the Azure Function, I can see the progress of Invoke-WebRequest. When it runs normally, it looks like this:
PROGRESS: Reading response stream... (Number of bytes read: 0)
PROGRESS: Reading response stream... (Number of bytes read: 3276)
PROGRESS: Reading response stream... (Number of bytes read: 13276)
PROGRESS: Reading response stream... (Number of bytes read: 23276)
PROGRESS: Reading response stream... (Number of bytes read: 27864)
...
...
PROGRESS: Reading response stream... (Number of bytes read: 256662)
PROGRESS: Reading web response completed. (Number of bytes read: 256662)
However, when it has a problem, it will halt after a random number of bytes read. Verbose logs will continue to output from normal operation of the Azure Function. The Activity Function times out after 10 minutes, at which point the Orchestrator finishes.
Normally, the API request takes under 30 seconds to complete -- usually it completes in under 10 seconds. But since the web stream from Invoke-WebRequest is hanging the Activity Function up, I cannot implement Durable Retry or Durable Wait in the Orchestrator function. I've tried wrapping each Invoke-WebRequest in Start-ThreadJob within Get-APIResource and using Wait-Job with a 30 second timeout. I'm able to properly throw an error from the API function to the Activity function, and the Orchestrator function catches it, but the Activity Function still sits there and waits until 10 minutes to time out because the thread job is locked up thanks to the Invoke-WebRequest stream.
I cannot reproduce this problem locally (via manual execution of Get-APIResource or via Azure Function debugging in VS Code) or on an Azure VM. I can fairly reliably reproduce this problem within Azure Automation Accounts / Runbooks and Azure Functions.
I've been chasing this error down since at least September 2023. I'm happy to share any other required information to help track this down.
The text was updated successfully, but these errors were encountered:
I have no idea why I'm unable to reproduce the error calling the class directly. My guess is it's some perfect storm between the language runtime, Invoke-WebRequest, and the remote API in question. Hope this helps someone else.
I have a function that uses Invoke-WebRequest in order to pull data from an external API. Here's a sanitzed version of the function:
I'm using it in an Activity function, like so:
And this is being called by an Orchestrator function:
When I look at Log Stream in the Azure Function, I can see the progress of
Invoke-WebRequest
. When it runs normally, it looks like this:However, when it has a problem, it will halt after a random number of bytes read. Verbose logs will continue to output from normal operation of the Azure Function. The Activity Function times out after 10 minutes, at which point the Orchestrator finishes.
Normally, the API request takes under 30 seconds to complete -- usually it completes in under 10 seconds. But since the web stream from
Invoke-WebRequest
is hanging the Activity Function up, I cannot implement Durable Retry or Durable Wait in the Orchestrator function. I've tried wrapping eachInvoke-WebRequest
inStart-ThreadJob
withinGet-APIResource
and usingWait-Job
with a 30 second timeout. I'm able to properly throw an error from the API function to the Activity function, and the Orchestrator function catches it, but the Activity Function still sits there and waits until 10 minutes to time out because the thread job is locked up thanks to theInvoke-WebRequest
stream.I cannot reproduce this problem locally (via manual execution of
Get-APIResource
or via Azure Function debugging in VS Code) or on an Azure VM. I can fairly reliably reproduce this problem within Azure Automation Accounts / Runbooks and Azure Functions.I've been chasing this error down since at least September 2023. I'm happy to share any other required information to help track this down.
The text was updated successfully, but these errors were encountered: