pnp / PnP-PowerShell

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

New-PnPSite Command started failing #2139

Open hsamdani12 opened 5 years ago

hsamdani12 commented 5 years ago

We started having intermittent issue when executing the Site Creation Script and it was caused at the point when New-PnPSite Script is being called. This used to work fine and now we have been having issues. I did open a ticket with Microsoft and they mentioned it takes sometime to create the SharePoint Site, but that has been the case even before. Please let me know if there is any solution or workaround for this ?

$teamSiteUrl = New-PnPSite -Type TeamSite -Title "teamsitetest" -Alias "teamsitetest" -Description "teamsite testing"

Expected behavior

It should have created the site without error.

Actual behavior

Error Message - New-PnPSite : {"DocumentsUrl":null,"ErrorMessage":null,"GroupId":"bee9e34b-05b2-4580-9455-5167ca03198f","SiteStatus":1,"SiteUrl":null}

Steps to reproduce behavior

Connect-PnPOnline -url "https://.sharepoint.com" $teamSiteUrl = New-PnPSite -Type TeamSite -Title "teamsitetesting" -Alias "teamsitetesting" -Description "team sitetesting"

SharePointPnPPowerShellOnline 3.9.1905.2

How did you install the PnP-PowerShell Cmdlets?

[ ] Installed through the PowerShell Gallery with Install-Module

ghost commented 5 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

Thijsman commented 5 years ago

Same issue experienced here..

hsamdani12 commented 5 years ago

So what is the resolution for this ? It looks like it does create the O365 Group and then it fails with error SiteStatus":1

mohrehm commented 5 years ago

This is an intermittent issue. I have an Azure Automation script that ran this command four times in the past hour. It went through smoothly the first two times, the remaining two times it threw an error but still provisioned the group.

hsamdani12 commented 5 years ago

hi thanks. It looks like the New-PnPSite command uses the following API - This is a Microsoft API to create a Modern Group Site, but it fails intermittently and causes the issue. Is this a Microsoft issue or PnP ?

POST /_api/GroupSiteManager/CreateGroupEx HTTP/1.1 {
"displayName":"Site Display name", "alias":"alias", "isPublic":true, "optionalParams":{
"Description":"Description for my group", "Owners":[
"emailaddress@contoso.com", "emailaddress@contoso.com" ] } }

pmatthews05 commented 5 years ago

Same issue here. Using version 3.10.1906.0

jahidmahedi commented 5 years ago

Having same issue here as well. The script worked for me if i try approx in 30mins interval. Using version 3.10.1906.0

nicolasbotto commented 5 years ago

Any updateS?

advdberg commented 5 years ago

Same issue overhere, 3.9.1905.1. New-PnPSite started failing around 3 days ago at several tenants of ourselves and our customers (target release and also regular)

As we're catching errors in our provisioning mechanism, this breaks the provisioning 'flow' and the same action is retried. On the retry it seems that the group is created correctly in the end. In that case we try to update the web property bag of the associated web which then also fails for the first time and after retrying that after a minute or so, it works fine.

So it looks like the provisioning of the site is delayed in this case which is then causing issues in a common provisioning scenario.

@erwinvanhunen @VesaJuvonen @andrewconnell it seems like a 'breaking' issue in the SharePoint CSOM API used by the New-PnPSite function, is this already a known issue and if so. any news on that?

Wadneyare commented 5 years ago

when I use the version New-PnPSite -Alias "something" it is causing error. however the site will be created but it catch's the error …."Site url is null......". if I close the session and wait for long time or restart my pc it works fine for one time however if I close the session and repeat it creates the site but shows the error.in any case the error Site_url error has no relation with this version of the command because there is no siturl input, hence it seems as it switchs the other New-PnPSite which has url input.

mohrehm commented 5 years ago

As a workaround, I am using New-UnifiedGroup. The workflow is a bit different but gets the job done. Any idea how different New-PnPSite is from New-UnifiedGroup in terms of services provisioned? Any other not-so-obvious differences?

Wadneyare commented 5 years ago

As far as I know the New-UnifiedGroup is used for exchange and New-PnPSite is used for sharepoint to create modern site and office groups who own the site. Office groups can be created many different ways, so as long as job done it is the best practice to keep using the right command.

hsamdani12 commented 5 years ago

Here is a response from the SharePoint Engineering team -

New-PnPSite uses the /_api/GroupSiteManager/CreateGroupEx API endpoint behind of the scenes. Pretty recently execution of this has no longer been immediate, there has been a delay with the site creation. That’s what the status 1 means in the exception (see codes from https://docs.microsoft.com/en-us/sharepoint/dev/apis/site-creation-rest#get-modern-site-status https://can01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fapis%2Fsite-creation-rest%23get-modern-site-status&data=02%7C01%7CHarsh.Samdani%40ontario.ca%7C0f56da1c553542f6548908d6ffbd7a7d%7Ccddc1229ac2a4b97b78a0e5cacb5865c%7C0%7C0%7C636977586633794223&sdata=RLeiWiBE74JGkN1xhGC5lAppbmToTE2ym67vF9IQyLE%3D&reserved=0). Unfortunately the open-sourced New-PnPSite was not prepared for this change, which is why the exception is now thrown.

The next release of New-PNPSite will occur in late August which will provide a fix to this wrapper solution. You can however tackle the solution by waiting for example few minutes in the case of an exception with status code 1… as that means that site creation is in progress, but not there.

I recommend parsing the return JSON and handling the status below for handling the group creation with the New-PnPSite cmdlet.

This is not an optimal situation, but below code does provide a workaround until status handling support is included in the New-PnPSite cmdlet natively.

On Jul 3, 2019, at 1:45 PM, Wadneyare notifications@github.com wrote:

As far as I know the New-UnifiedGroup is used for exchange and New-PnPSite is used for sharepoint to create modern site and office groups who own the site. Office groups can be created many different ways, so as long as job done it is the best practice to keep using the right command.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/SharePoint/PnP-PowerShell/issues/2139?email_source=notifications&email_token=AJB2C44TBGYTHHDSAMT4UKLP5TQVLA5CNFSM4H3CJLD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZFGFKA#issuecomment-508191400, or mute the thread https://github.com/notifications/unsubscribe-auth/AJB2C45SXJXHVZPUZMYO3F3P5TQVLANCNFSM4H3CJLDQ.

Wadneyare commented 5 years ago

Thank you Guys! I updated the SharePointPnPPowerShellOnline to Version: 3.11.1907.0 and everything is working fine now and client is happy. Good job and keep updating us.

jackpoz commented 5 years ago

https://github.com/SharePoint/PnP-Sites-Core/pull/2319 is supposed to fix this issue