I am trying to get a user to run a powershell script through an Azure function. This script is supposed to create a site on SharePoint with some info provided by users.
I created an Azure Function App to run some PowerShell scripts. When I tried to run my code, it returned an error http 502
at Connect-PnPOnline
If I remove Connect-PnPOnline
, I get a 200 response. So I am sure that it has to do with Connect-PnPOnline
in my script.
I followed the post by @Lee_MSFT Get PowerShell Script to Run SharePoint Commands on Azure and able to import modules.
using namespace System.Net
param (
[string]$projectnumber,
[string]$projectname
)
$site = "https://xxxxx.sharepoint.com/sites/projects"
$projectsite = -join($site, "/", $projectnumber)
$projecttitle = -join($projectnumber, " ", $projectname)
Connect-PnPOnline -url $site
...
I got 500 from Connect-PnPOnline -url $site
and a 502 from Connect-PnPOnline -url $site -UseWebLogin
Anyone know that why I have 5xx errors while using Connect-PnPOnline
?
Thanks a lot!
Connect-PnPOnline -AppId '<id>' -AppSecret '<secret>' -AADDomain 'contoso.onmicrosoft.com'
. If your account is not MFA-enabled, I think the way provided by Lee_MSFT will work.