pnp / pnpframework

PnP Framework is a .NET library targeting Microsoft 365 containing the PnP Provisioning engine and a ton of other useful extensions
https://pnp.github.io/pnpframework/
MIT License
210 stars 145 forks source link

Issue running Invoke-PnpSiteTemplate inside azure automation #381

Open ahmedrafeq opened 3 years ago

ahmedrafeq commented 3 years ago

Using Invoke-PnPSiteTemplate inside Azure Automation Runbook. the script runs successfully locally, but when running inside Azure Automation, get the error below when Invoke command is run.

Method not found: 'System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1Boolean Enumerator.MoveNextAsync()'.

The template was generated using get-pnpsitetemplate The template has few components:

  1. Documents library (folders and files).
  2. Events web part along with sp list.
  3. Quick links web part.
  4. Two text web part.
  5. Countdown timer web part.

Pnp version 1.6

Thanks

Nibushi commented 3 years ago

I was receiving the exact same error message when running Invoke-PnPSiteTemplate locally but it was due to VS Code trying to target PowerShell v5 instead of v7.1.

If you haven't done so already, you might want to check your Azure Automation Runbook is targeting the right PowerShell version.

Bart2s4 commented 3 years ago

It is interesting that the powershell version is the issue, but how can i target powershell 7.1 because this is "coming soon", meanwhile all my runbooks cannot complete the pnp template (clientsidepages) because of this error, is there a work a round, because my customer cannot roll out new templates due to this error.

dremillard commented 1 year ago

I have this same error using PowerShell 5. It did go away when I moved to PowerShell 7, but then I learned I couldn't use PowerShell 7 because it has an issue with how it parses JSON when it's called from a webhookk in an Azure Runbook.

This is documented here under "Create a webhook": https://learn.microsoft.com/en-us/azure/automation/automation-webhooks?tabs=portal.

So now I'm back to looking for a workaround. Anyone else bump into this issue?