pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
985 stars 665 forks source link

[BUG] - Get-PnPTenantSite is sometimes not NULL when site does not exist #2997

Open paylord opened 3 years ago

paylord commented 3 years ago

2857 # Reporting an Issue or Missing Feature

I am using PnP PowerShell in an Azure Function App to provision new sites/Teams. I use the following to check if a site exists:

$site = Get-PnPTenantSite -Url $existingUrl -ErrorAction SilentlyContinue; if ($null -ne $site) {

Site already exists

Write-Output "Site already exists - stopping further processing: $($site | Out-String)";

}

When requests go through one at a time then all works as expected.

Expected behavior

$site = Get-PnPTenantSite -Url $existingUrl -ErrorAction SilentlyContinue; This should return $null if the site does not exists. Note that I appreciate it may be in the recycle bin - I do check for this separately.

Actual behavior

If multiple requests are triggered at the same time then $site does not return $null as expected. The following is what I see in the Azure function log:

Site already exists - stopping further processing: Url Template Lcid --- -------- ----

If I re-trigger this request with the same URL then it succeeds.

I have tried to reproduce this from a PS console without success. It feels like I get a different response if a site is in the process of being created?

Steps to reproduce behavior

See above comment. I have not been able to reproduce this issue in a PowerShell console - even running two side by side and creating a new site in one and using Get-PnPSite in the other.

Note that sites are created in the function app with a call to the Graph API to create a group.

Which version of the PnP-PowerShell Cmdlets are you using?

What is the version of the Cmdlet module you are running?

3.23.2007.1

How did you install the PnP-PowerShell Cmdlets?