pnp / powershell

PnP PowerShell
https://pnp.github.io/powershell
MIT License
655 stars 337 forks source link

[FEATURE] Export-PnPFlow - Add options to capture errors, increase timeout, retry attempts #1340

Open robertcaretta opened 2 years ago

robertcaretta commented 2 years ago

Is your feature request related to a problem? Please describe. Koen recently added verbose information to Export-PnPFlow. I was hoping this could be expanded for error trapping purposes. https://github.com/pnp/powershell/issues/865#event-5404518820

Describe the solution you'd like I would like to be able to capture errors from Export-PnPflow with ErrorAction and/or ErrorVariable so I can send those to a log file and provide email notifications.

Describe alternatives you've considered Here is a work-around I have created. This feels like a hack. I think a more formal approach would be better.

$VerboseStream = (Export-PnPFlow -Environment $globals.envGUID -Identity $_.Flow_FlowName -OutPath $outPath -AsZipPackage -Verbose | Tee-Object -Variable 'String' | Out-Null) 4>&1

if($VerboseStream -like 'error') { }

robertcaretta commented 2 years ago

Can you also option for the follwings: 1) Increasing the HttpClient.Timeout 2) Retry option

2021-12-08_15-32-43

gautamdsheth commented 2 years ago

You can maybe increase the timeout by adding this environment variable like below:

$env:SharePointPnPHttpTimeout = 300

and then use the Export-PnPFlow command, maybe that can help ?

robertcaretta commented 2 years ago

Okay I will try that. Thanks for the suggested.

Hopefully the other ideas I posted will be considered to make this cmdlet more resilient.

On Sat, Mar 5, 2022 at 9:49 AM Gautam Sheth @.***> wrote:

You can maybe increase the timeout by adding this environment variable like below:

$env:SharePointPnPHttpTimeout = 300

and then use the Export-PnPFlow command, maybe that can help ?

— Reply to this email directly, view it on GitHub https://github.com/pnp/powershell/issues/1340#issuecomment-1059786264, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMJ2HICBLPD6O2QN5L4TLTU6N7CPANCNFSM5H3NWANA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

robertcaretta commented 2 years ago

@gautamdsheth - I am getting back into testing this process I am working on. I added the variable you suggested above. I'm seeing it take 5 minutes to establish a connection with Connect-PnPOnline? I am using a service account that doesn't require MFA. Typically a connection takes 1-2 seconds. I can see in the Azure AD logs that it is showing the 12:10 time. So it's not hitting Azure for 5 minutes.

Is this to be expected now? Or is there some kind of new/temporary problem?

2022-03-25_12-11-45