pnp / PnP

SharePoint / Office 365 Developer Patterns and Practices - Archived older solutions. Please see https://aka.ms/m365pnp for updated guidance
https://aka.ms/m365pnp
Other
1.89k stars 3.31k forks source link

Issues with PnP Powershell running concurrently from Azure Runbooks inside a try/catch block #1881

Open antoniobriones opened 5 years ago

antoniobriones commented 5 years ago

Hi everyone,

We're facing the followng issue. We have a couple of Azure runbooks to automate the enablement of certain SharePoint features, like site collection app catalog enablement, external sharing enablement and scripting enablement.

For each of them, we have one runbook that receives the site url, connects to the admin center and enables the feature.

The code of all the runbooks is pretty similar, being the only difference just the PnP command they run:

image

image

The PnP commands we're using are:

We're randomnly finding the following issue that only happens if we run those runbooks at the same time. In those cases, the 30% of the time we'll face the following:

Set-PnPTenantSite : Object reference not set to an instance of an object. At line:41 char:9

Connect-PnPOnline : Token request failed. At line:31 char:5

Set-PnPTenantSite : No connection, please connect first with Connect-PnPOnline At line:41 char:9

Add-PnPSiteCollectionAppCatalog : Object reference not set to an instance of an object.

Background info:

Thanks!

russgove commented 5 years ago

Not sure if it's causing your issue, but when running pnp powershell in azure runbooks you need to always assign the return result to a variable - even if u don't use the variable,

antoniobriones commented 5 years ago

Thanks @russgove, so you suggest that would the correct approach to determine whether the operation was succesful or not. Regardless of that, the weird thing is why it is randomnly raising exceptions.