Habibur Rahaman

Habibur Rahaman

  • 326
  • 5k
  • 811.3k

Error in New-PnPWeb SharePoint Azure function.

Dec 28 2018 12:05 AM
Hi,
 
I was trying to execute the below code from Azure function for site creation in sharepoint online.
 
$requestBody= Get-Content$triggerInput-Raw| ConvertFrom-Json
$ParentSiteUrl = "https://spfire.sharepoint.com/sites/projectsitecreation/"
$WebTemplate = $requestBody.WebTemplate
$SiteTitle = $requestBody.SiteTitle
$SiteDescription = "Site with PowerShell"
$SiteURL = $requestBody.SiteURL
$SiteLanguage = $requestBody.SiteLanguage
$AppId = $env:AppId
$AppSecret = $env:AppSecret
connect-PnPOnline -AppId $AppId -AppSecret $AppSecret -url $ParentSiteUrl
New-PnPWeb -Title $SiteTitle -url $SiteURL -Locale $SiteLanguage -Template $WebTemplate -Description$SiteDescription
Write-Output "PowerShell script processed queue message '$<sub></sub><sup></sup><strike></strike>
 
18-12-27T11:35:11 Welcome, you are now connected to log-streaming service.
2018-12-27T11:35:16.414 [Info] Function started (Id=".....")
2018-12-27T11:35:17.508 [Error] New-PnPWeb : Access denied. You do not have permission to perform this action or access this resource.
at run.ps1: line 32
2018-12-27T11:35:17.555 [Error] Exception while executing function: Functions.QueueTriggerPowerShellSiteCreation. Microsoft.Azure.WebJobs.Script: PowerShell script error. Microsoft.SharePoint.Client.Runtime: Access denied. You do not have permission to perform this action or access this resource.
 
What could be possible reason for this error...as I have followed up the instruction as is.
 
Reference Url: https://www.sharepointfire.com/2018/04/sharepoint-online-pnp-site-provisioning-using-flow-and-azure-function/
 
Thanks,
Habibur Rahaman

Answers (1)