Forum Discussion
Deploy provisioning templates with Azure Automation, PnP PowerShell Apply-ProvisioningTemplate error
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?
If you set debug on with
Set-SPOTraceLog -On -Level Debug
then you will see where the application of the template fails.
2 Replies
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