【问题标题】:Applying PnP Provisioning template with Azure Functions/Powershell使用 Azure Functions/Powershell 应用 PnP 预配模板
【发布时间】:2019-07-31 17:59:39
【问题描述】:

我目前正在尝试开发一个流,它创建一个 SharePoint 网站,然后利用 Azure 函数为所述网站提供一系列库等。

Flow 本身非常简单,但我正在努力解决的是 Azure 函数本身,尤其是身份验证;它使用Connect-PnPOnline cmdlet,而我们的租户使用 MFA,我在绕过它时遇到了一些困难——我创建了一个服务主体用户,它至少使我能够连接到该站点,但我仍然不能真正使用Apply-PnPProvisioningTemplate,也不能真正使用任何其他 PnP 命令 - 当我尝试这样做时,我得到:

“远程服务器返回错误:(403) Forbidden。”

我的服务主体用户具有贡献权限,以及 Sites.FullControl.All 的范围,所以我不确定我哪里出错了。

请参阅下面的 Powershell 代码 - 我不认为问题真的是从那里出现的,但显示出来也无妨:

$requestBody = Get-Content $req -Raw | ConvertFrom-Json

"destination": "SharePointSiteURL"


$destination = $requestBody.destination
$secpasswd = ConvertTo-SecureString $env:pass -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ($env:user, $secpasswd)
Connect-PnPOnline -url $destination -AppID $env:user -AppSecret $env:pass
Apply-PnPProvisioningTemplate -path "D:\home\site\wwwroot\template.xml"
Out-File -Encoding Ascii -FilePath $res -inputObject "Done $destination"

我应该注意,这实际上是我第一次使用 Azure Functions,如果这里的解决方案非常简单,请原谅我!任何帮助将不胜感激。

【问题讨论】:

    标签: azure powershell azure-functions


    【解决方案1】:
    猜你喜欢
    • 2021-10-28
    • 2016-08-18
    • 2021-01-27
    • 2021-12-05
    • 2020-05-21
    • 1970-01-01
    • 1970-01-01
    • 2023-03-31
    • 2019-04-25
    相关资源
    最近更新 更多