All the examples I've come across for applying a provisioning template involve reading the template from a physical file path. I would like to create an in memory template reading from an xml string and then call Apply-PnPProvisioningTemplate. Reason being I'm executing the powershell script in Azure function and I'm passing the template as a string parameter to the azure function. I've tried creating a template object using New-PnPProvisioningTemplate, but after that I couldn't figure out how to set the template with the xml supplied. I looked at Read-PnPProvisioningTemplate, but that also expects a file path as input.
There is and XMLAzureStorageTemplateProvider for connecting to Azure storage. Its usage can be seen here in the units tests:
But indeed it seems like there currently is no easy way to get the template directly from string. But it is definitely doable from a technical standpoint (although using PnP-Sites-Core classes).
Here are samples on how this could be implemented:
@jansenbe is there a reason why applying a template from string (instead of file) should not be exposed?
I'm working on a update to the engine which will allow you to initialize a provisioning template from a stream using a new provider. Together with this change I will update the Read-PnPProvisioningTemplate cmdlet to support an -Xml parameter:
$template = Read-PnPProvisioningTemplate -Xml $yourtemplatestring
Apply-PnPProvisioningTemplate -InputInstance $template
The functionality will be available in the next release of PnP PowerShell.
Terrific!
Thanks Erwin and Heinrich. You guys are awesome. When is the next release expected?
On Friday, April 26, 2019, 7:25:06 PM GMT+1, Heinrich Ulbricht notifications@github.com wrote:
Terrific!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
Most helpful comment
The functionality will be available in the next release of PnP PowerShell.