sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

Site design applied twice when invoked programmaticaly

Open BigBd1 opened this issue 7 years ago • 7 comments

Category

  • [ ] Question
  • [ ] Typo
  • [x ] Bug
  • [ ] Additional article idea

Expected or Desired Behavior

I have a powershell script meant to be run in a Azure Runbook which create a modern site and invoke a site design. The site design is composed with a site script with only one action (trigger a logic app). The logic app has a quite long running process (from 3min to 10min).

Observed Behavior

In 80% of the cases, the site design is applied twice and my logic app is also triggered twice. I used the cmdlet Get-SPOSiteDesignRun in order to see what happened and here is the result :

Id                : 5dd9a40a-6a10-4576-8475-debd12d53c3a
SiteDesignId      : 16b3b3eb-5d26-46aa-89ed-ea8f4f53a92a
WebId             : d20678e9-4d78-4afa-864a-3fbdf328558d
SiteId            : a864955d-5127-471c-8cd0-d345d45ca40c
SiteDesignVersion : 1
SiteDesignTitle   : Test Logic App Site Design

Id                : 00000000-0000-0000-0000-000000000000
SiteDesignId      : 16b3b3eb-5d26-46aa-89ed-ea8f4f53a92a
WebId             : d20678e9-4d78-4afa-864a-3fbdf328558d
SiteId            : a864955d-5127-471c-8cd0-d345d45ca40c
SiteDesignVersion : 1
SiteDesignTitle   : Test Logic App Site Design

We saw that the site design is really applied twice (by the way the first run identifier is weird). If I run Get-SPOSiteDesignRun right after the site design invocation I see only one run, the second one happens 30s-1min later.

I checked the two incoming requests in the logic app run history and bodies are the same, the only difference are the headers "x-ms-client-request-id" and "X-SharePoint-Created-By" whose correlation ids are different.

I don't encounter this issue by using the SharePoint UI to create my team site with this site design. But in this case, I noticed there is a delay before the site design is applied by using Get-SPOSiteDesignRun right after the site was available.

The random behavior of this bug and the behavior using the UI make me think that I cannot apply a site design right after the site creation because SharePoint might be still doing some underground stuff. I added a Start-Sleep -s 120 after the site creation and before the site design invocation and it seems to have a 100% success ratio.

Steps to Reproduce

Juste execute a simple powershell script like that which create a site and apply a site design. I didn't test if the bug is present with another site script action but I think it will.

$cred = Get-Credential 
Connect-SPOService -Url 'https://tenant-admin.sharepoint.com/' -Credential $cred 
$teamSiteUrl = ""
$siteDesign = Get-SPOSiteDesign | Where-Object {$_.Title -eq "Test Logic App Site Design"} 

if (-not $siteDesign) {
    throw "The specified site design was not found"
}

Connect-PnpOnline -Url 'https://tenant.sharepoint.com/' -Credentials $cred 

$siteName = "TestSiteDesignFromPS"

Switch ($siteDesign.WebTemplate) {
    # Team Site 
    64 {$teamSiteUrl = New-PnpSite -Type TeamSite -Title $siteName -Alias $siteName; break}
    
    # Communication Site
    68 {$teamSiteUrl = New-PnpSite -Type CommunicationSite -Title $siteName -Alias $siteName; break}
}        
$invocationResult = Invoke-SPOSiteDesign -Identity $siteDesign -WebUrl $teamSiteUrl 

Thanks in advance for your assistance !

BigBd1 avatar Jan 21 '19 14:01 BigBd1

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

msft-github-bot avatar Jan 21 '19 14:01 msft-github-bot

A couple simple questions -

  1. You didn't by chance make this site design default did you?
  2. By chance do you have two site designs deployed to SharePoint with the same name?

bcameron1231 avatar Jan 21 '19 15:01 bcameron1231

@bcameron1231

No unfortunately it is not the default site design and I have pushed only one site design to my tenant :


PS C:\WINDOWS\system32> Get-SPOSiteDesign | Where-Object {$_.Title -eq 'Test Logic App Site Design'}


Id                  : 16b3b3eb-5d26-46aa-89ed-ea8f4f53a92a
Title               : Test Logic App Site Design
WebTemplate         : 64
SiteScriptIds       : {722fbc40-5560-42a2-be14-1041a0f37221}
Description         :
PreviewImageUrl     :
PreviewImageAltText :
IsDefault           : False
Version             : 1
DesignPackageId     : 00000000-0000-0000-0000-000000000000

BigBd1 avatar Jan 21 '19 15:01 BigBd1

Hi,

Did someone found an explanation for this? Funny enough I'm seeing this behaviour (site design applied twice) when applying it through the SharePoint UI!

In my case, I have a site design which is only triggering a flow, which ends up triggering an Azure function to perform some configuration. The problem is the flow (and hence the Azure function) is being triggered twice, resulting in some unexpected behaviours. Any ideas on what can be causing the flow to trigger twice? Any suggestion would be really useful as I'm a bit desperate.

DaniCorretja avatar Nov 10 '19 16:11 DaniCorretja

I have exactly the same issue... In my case, I use the Azure Logic app instead of a flow. Steps to reproduce:

  • Create a site design with a site script with only one action "triggerFlow"
  • Create a new site using a custom site design from SharePoint Admin UI
  • The logic app gets triggered twice with interval 10-30 seconds

The same way Get-SPOSiteDesignRun -WebUrl "<site url>" returns two records instead of one.

s-KaiNet avatar Nov 12 '19 06:11 s-KaiNet

This issue is being closed as part of an issue list cleanup project. Issues with no activity in the past 6 months that aren't tracked by engineering as bugs were closed as part of this inititive. If this is still an issue, please follow the steps outlined to re-open or submit a new issue.

ghost avatar Dec 29 '21 16:12 ghost

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

ghost avatar Jan 06 '22 00:01 ghost