Azure Automation Runbooks and Foreach-Object -Parallel

shabarinath 1 Reputation point
2022-10-28T10:57:29.437+00:00

Dear Experts !

I have an automation runbook, configured with Powershell 7.1.
The same script works from my laptop on Powershell 7.2 without any issue.
I am using multithreading using the below codeblock.

$Input |Foreach-Object -ThrottleLimit 20 -Parallel {
Process Something
Return value
}

This works well on my laptop and I am able to complete the entire job in less than 30 minutes.
For some reason, The same script when configured through a runbook is taking 2 hours.

Are you aware of any such limitations with using -parallel switch within runbooks?

Thanks,
Shaba

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,162 questions
{count} votes

1 answer

Sort by: Most helpful
  1. tbgangav-MSFT 10,411 Reputation points
    2022-11-04T10:04:50.907+00:00

    Hi @shabarinath ,

    As per this Azure documentation, there are no limitations with using -parallel switch within runbooks.

    Is there a reason for trying PowerShell 7.1 in Azure Automation?
    Can you try PowerShell 7.2 and see if the experience is same or not?
    Excluding any PII information, can you share the actual runbook code so I can try to reproduce the issue in my lab environment?

    0 comments No comments