首页 > 解决方案 > 如何在 Azure PowerShell Runbook 上应用 SharePoint 网站模板?

问题描述

如何通过 PowerShell Azure Runbook 将 SharePoint 网站模板(保存为我的 One Drive 中的 XML 文件)应用到新创建的网站?

目前,在我的本地机器上,我使用Apply-PnPProvisioningTemplate -Path "path to XML file" -ClearNavigation

我不知道在哪里存储 XML 文件,或者如何使用 Runbook 访问它,谢谢

标签: azurepowershellsharepointonedriveazure-runbook

解决方案


您可以将 xml 文件存储在 blob 存储中,然后在 azure runbook -> 从 blob 存储下载 xml 文件。

Runbook 中的代码如下:

#download xml file from blob storage

 $account_name = "blob_storage_account_name"
 $account_key = "blob_storage_account_key"

$context = New-AzStorageContext -StorageAccountName $account_name -StorageAccountKey $account_key

$xml_name_local="your_xml_name_when_download_to_local"
$blob_name = "your_xml"
$container_name = "container_stored_xml_file"

Get-AzStorageBlobContent -Blob $blob_name -Container $container_name -Destination "$Env:temp\$xml_name_local" -Context $context

#then you can use "$Env:temp\$xml_name_local" to replace "path to XML file"

Apply-PnPProvisioningTemplate -Path "path to XML file" -ClearNavigation

推荐阅读