invoke-azruncommand in Azure Function getting timed out

Sumit Dubey 0 Reputation points
2023-04-12T17:56:30.59+00:00

Hi ,
While Invoking AZ Run Command from Azure Function , its getting timed out. I'm using consumption based plan. Its a HTTP Trigger . I'm running this as a Job to bypass if script get stuck for more than 120 seconds. Initially I was using Sleep parameter but that seems to put function in Sleep. Then I used For loop to avoid sleep but still loop runs for sometime & then no data

$newJob=Invoke-AzVMRunCommand -ResourceGroupName $result.ResourceGroupName -Name $result.Name -CommandId 'RunPowerShellScript'  -ScriptPath $winfullPath -asjob


Invoke-WebRequest : 500 - The request timed out.           500 - The request timed out.  The web server failed to respond within the specified time.
At line:27 char:17
+ $LogicAppInfo = Invoke-WebRequest -Uri $LogicAppsUrl -Headers @{
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,371 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,150 questions
{count} votes