pnpframework icon indicating copy to clipboard operation
pnpframework copied to clipboard

Invoke-PnPSiteTemplate: App Install timeout hit, could not determine installed state

Open Ron-Rohlfs opened this issue 1 year ago • 1 comments

Expected behavior: Execute without issue

Actual behavior: Error message: App Install timeout hit, could not determine installed state Stack trace: PnP.Framework.Provisioning.ObjectHandlers.ObjectApplicationLifecycleManagement.PollforAppInstalled(AppManager manager, Guid appId) at PnP.Framework.Provisioning.ObjectHandlers.ObjectApplicationLifecycleManagement.ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation) at PnP.Framework.Provisioning.ObjectHandlers.SiteToTemplateConversion.ApplyRemoteTemplate(Web web, ProvisioningTemplate template, ProvisioningTemplateApplyingInformation provisioningInfo, Boolean calledFromHierarchy, TokenParser tokenParser) at PnP.PowerShell.Commands.Provisioning.Site.InvokeSiteTemplate.ExecuteCmdlet() in c:\build\src\Commands\Provisioning\Site\InvokeSiteTemplate.cs:line 0 at PnP.PowerShell.Commands.Base.PnPConnectedCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPConnectedCmdlet.cs:line 53

Steps to reproduce behavior: $siteTemplateConn = Connect-PnPOnline -Url $siteTemplateUrl -ManagedIdentity:$true -ReturnConnection:$true -ErrorAction Stop; Get-PnPSiteTemplate -Connection $siteTemplateConn -IncludeAllPages:$true -IncludeSiteGroups:$true -Out "sitetemplate.pnp" -ExcludeHandlers SiteSecurity -Force:$true -ErrorAction Stop; $siteTemplateDocumentsLibrary = Get-PnPList -Connection $siteTemplateConn -Identity 'Documents' -ThrowExceptionIfListNotFound:$true -ErrorAction Stop; Add-PnPListFoldersToSiteTemplate -Connection $siteTemplateConn -Path "sitetemplate.pnp" -List $siteTemplateDocumentsLibrary -Recursive:$true -ErrorAction: Stop; $targetSiteConn = Connect-PnPOnline -Url $SiteUrl -ManagedIdentity:$true -ReturnConnection:$true -ErrorAction Stop); Invoke-PnPSiteTemplate -Connection $targetSiteConn -Path ".\sitetemplate.pnp" -ExcludeHandlers ComposedLook -ClearNavigation:$true -ErrorAction Stop;

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

Which operating system/environment are you running PnP PowerShell on? Azure PowerShell Runbook Runtime version 7.2

Ron-Rohlfs avatar May 02 '23 19:05 Ron-Rohlfs

I am also facing this issue.

As per this,

The ALM API's just trigger the installation process, the "install" call is actually asynchronous and finishes before the app is actually installed. To work around this, the PnP code goes into a loop and uses a different API call to check install status every 5 seconds for 5 minutes.

private void PollforAppInstalled(AppManager manager, Guid appId)
        {
            Stopwatch sw = new Stopwatch();
            sw.Start();
            var appMetadata = manager.GetAvailable(appId, Enums.AppCatalogScope.Tenant);
            while (appMetadata.AppCatalogVersion != appMetadata.InstalledVersion && sw.ElapsedMilliseconds < 1000 * 60 * 5)
            {
                System.Threading.Thread.Sleep(5000); // sleep 5 seconds and try again
                appMetadata = manager.GetAvailable(appId, Enums.AppCatalogScope.Tenant);
            }
            if (appMetadata.AppCatalogVersion != appMetadata.InstalledVersion)
            {
                // We ran into a timeout
                throw new Exception("App Install timeout hit, could not determine installed state");
            }
            sw.Stop();
        }

PnP Should provide functionality to set this static 5 minutes timeout some how or it should be increased at list for 10 minutes,

kavaghela avatar May 16 '23 04:05 kavaghela