SOLVED

Deploy provisioning templates with Azure Automation, PnP PowerShell Apply-ProvisioningTemplate error

%3CLINGO-SUB%20id%3D%22lingo-sub-16854%22%20slang%3D%22en-US%22%3EDeploy%20provisioning%20templates%20with%20Azure%20Automation%2C%20PnP%20PowerShell%20Apply-ProvisioningTemplate%20error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-16854%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20transferring%20a%20local%20script%20hosted%20on%20a%20PC%20to%20deploy%20SharePoint%20Site%20Collections%20and%20provision%20the%20root%20site%20using%20Office%20Dev%20PnP%20to%20Microsoft%20Azure.%20I%20want%20to%20deploy%20this%20script%20inside%20Microsoft%20Azure%2C%20so%20we%20can%20multiple%20users%20run%20the%20script%20to%26nbsp%3Bprovision%20sites.%3C%2FP%3E%3CP%3EWe%20know%20the%20PnP%20Partner%20Pack%202.0%20exists%2C%20but%20this%20came%20a%20bit%20too%20late%20for%20this%20project%2C%20so%20we%20decided%20to%20build%20this%20using%20a%20SharePoint%20list%20and%20multiple%20Azure%20components.%20Everything%20works%20except%20the%20PnP%20PowerShell%20Apply-ProvisioningTemplate.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EInside%20Microsoft%20Azure%2C%20associated%20to%20the%20Office%20365%20tenant%20and%20corresponding%20SharePoint%20Online%20site%2C%20I've%20set%20up%20a%20PowerShell%20Workflow%20Runbook%20which%20hosts%20the%20script%20to%20configure%20the%20root%20site%20of%20a%20site.%3C%2FP%3E%3CP%3EI've%20imported%26nbsp%3Bthe%20SharePointPnPPowerShellOnline%202.7.1609.3%20modules%2C%20which%20allows%20me%20to%20use%20the%26nbsp%3BPnP%20PowerShell%20commands.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20Apply-SPOProvisioningTemplate%20command%20doesn't%20seem%20to%20work%20correctly.%26nbsp%3BI'm%20applying%20a%26nbsp%3Bprovisioning%20template%20that%20I%20have%20stored%20inside%20the%26nbsp%3BsharePoint%20site%2C%20so%20I'm%20using%20the%20following%20command%3C%2FP%3E%3CPRE%3EApply-SPOProvisioningTemplate%20-Path%20(%22https%3A%2F%2Fmytenant.sharepoint.com%2FSites%2FMySiteCollection%2FSiteAssets%2FMySiteTemplate.pnp%22)%20%20%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20template%20gets%20provisioned%2C%20e.g.%20fields%2C%20content%20types%2C%20lists%20and%20files%20are%20created.%20The%20script%20stops%20with%20the%20error%3A%3C%2FP%3E%3CPRE%3EValue%20cannot%20be%20null.%0AParameter%20name%3A%20stream%3C%2FPRE%3E%3CP%3EThe%20site%20pages%20are%20not%20deployed.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20using%20parameters%2C%20but%20non%20of%20them%20is%20called%20%22Stream%22%2C%20so%20I%20have%20no%20idea%20where%20this%20error%20comes%20from.%26nbsp%3BAlso%20when%20I%20use%20the%20-Handlers%20Files%20parameter%20to%20only%20deploy%20files%2C%20all%20files%20are%20deployed%20but%20after%20deployment%20the%20same%20error%20occurs.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20ideas%20how%20to%20fix%20this%20issue%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-17312%22%20slang%3D%22en-US%22%3ERe%3A%20Deploy%20provisioning%20templates%20with%20Azure%20Automation%2C%20PnP%20PowerShell%20Apply-ProvisioningTemplate%20e%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-17312%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F2387%22%20target%3D%22_blank%22%3E%40Pieter%20Veenstra%3C%2FA%3E%2C%26nbsp%3BI've%20managed%20to%20find%20my%20bug%20using%20the%20logging.%20I%20was%20missed%20a%20file%20referenced%20in%20a%20PnP%3AFiles%20element%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-17123%22%20slang%3D%22en-US%22%3ERe%3A%20Deploy%20provisioning%20templates%20with%20Azure%20Automation%2C%20PnP%20PowerShell%20Apply-ProvisioningTemplate%20e%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-17123%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20you%20set%20debug%20on%20with%3C%2FP%3E%3CP%3ESet-SPOTraceLog%20-On%20-Level%20Debug%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethen%20you%20will%20see%20where%20the%20application%20of%20the%20template%20fails.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Frequent Contributor

I'm transferring a local script hosted on a PC to deploy SharePoint Site Collections and provision the root site using Office Dev PnP to Microsoft Azure. I want to deploy this script inside Microsoft Azure, so we can multiple users run the script to provision sites.

We know the PnP Partner Pack 2.0 exists, but this came a bit too late for this project, so we decided to build this using a SharePoint list and multiple Azure components. Everything works except the PnP PowerShell Apply-ProvisioningTemplate.

 

Inside Microsoft Azure, associated to the Office 365 tenant and corresponding SharePoint Online site, I've set up a PowerShell Workflow Runbook which hosts the script to configure the root site of a site.

I've imported the SharePointPnPPowerShellOnline 2.7.1609.3 modules, which allows me to use the PnP PowerShell commands.

 

The Apply-SPOProvisioningTemplate command doesn't seem to work correctly. I'm applying a provisioning template that I have stored inside the sharePoint site, so I'm using the following command

Apply-SPOProvisioningTemplate -Path ("https://mytenant.sharepoint.com/Sites/MySiteCollection/SiteAssets/MySiteTemplate.pnp")  

 

The template gets provisioned, e.g. fields, content types, lists and files are created. The script stops with the error:

Value cannot be null.
Parameter name: stream

The site pages are not deployed.

 

I am using parameters, but non of them is called "Stream", so I have no idea where this error comes from. Also when I use the -Handlers Files parameter to only deploy files, all files are deployed but after deployment the same error occurs.

 

Any ideas how to fix this issue?

2 Replies
Highlighted
Best Response confirmed by Harold van de Kamp (Frequent Contributor)
Solution

If you set debug on with

Set-SPOTraceLog -On -Level Debug

 

then you will see where the application of the template fails.

Thank you @Pieter Veenstra, I've managed to find my bug using the logging. I was missed a file referenced in a PnP:Files element