Unable to provision modern site using provider hosted app in SharePoint 2019

%3CLINGO-SUB%20id%3D%22lingo-sub-764109%22%20slang%3D%22en-US%22%3EUnable%20to%20provision%20modern%20site%20using%20provider%20hosted%20app%20in%20SharePoint%202019%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-764109%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20are%20trying%20to%20create%20a%20modern%20site%20from%20the%20provider%20hosted%20app%20in%20SharePoint%202019.%3CBR%20%2F%3EWe%20have%20tried%20creating%20a%20modern%20site%20using%20SharePoint%20in-built(team%20%22STS%233%22%20and%20communication%20%22SITEPAGEPUBLISHING%230%22)%20site%20collection%20template%2C%20but%20it%20creates%20a%20classic%20site.%20Also%2C%20we%20have%20tried%20creating%20classic%20team%2Fcommunication%20site%20and%20added%20a%20modern%20page%20in%20that%20and%20saved%20that%20site%20as%20a%20template.%20Taking%20base%20as%20that%20template%2C%20we%20tried%20creating%20a%20modern%20site%2C%20but%20here%20also%20it%20creates%20a%20classic%20site%20only.%3C%2FP%3E%3CH4%20id%3D%22toc-hId-1400361155%22%20id%3D%22toc-hId-1400361183%22%20id%3D%22toc-hId-1400361183%22%20id%3D%22toc-hId-1400361183%22%20id%3D%22toc-hId-1400361183%22%20id%3D%22toc-hId-1400361183%22%20id%3D%22toc-hId-1400361183%22%20id%3D%22toc-hId-1400361183%22%3EEnvironment%3C%2FH4%3E%3CP%3E%5Bx%5D%20SharePoint%202019%3C%2FP%3E%3CP%3EBuild%20Name%3A%20SharePoint%20Server%202019%20RTM%3C%2FP%3E%3CP%3ECU%20Version%3A%2016.0.10337.12109%3C%2FP%3E%3CH4%20id%3D%22toc-hId--1151795806%22%20id%3D%22toc-hId--1151795778%22%20id%3D%22toc-hId--1151795778%22%20id%3D%22toc-hId--1151795778%22%20id%3D%22toc-hId--1151795778%22%20id%3D%22toc-hId--1151795778%22%20id%3D%22toc-hId--1151795778%22%20id%3D%22toc-hId--1151795778%22%3EExpected%20or%20Desired%20Behavior%3C%2FH4%3E%3CP%3EWe%20have%20tried%20creating%20a%20modern%20site%20using%20SharePoint%20in-built(team%20%22STS%233%22%20and%20communication%20%22SITEPAGEPUBLISHING%230%22)%20site%20collection%20template%2C%20It%20should%20create%20a%20modern%20site.%3C%2FP%3E%3CH4%20id%3D%22toc-hId-591014529%22%20id%3D%22toc-hId-591014557%22%20id%3D%22toc-hId-591014557%22%20id%3D%22toc-hId-591014557%22%20id%3D%22toc-hId-591014557%22%20id%3D%22toc-hId-591014557%22%20id%3D%22toc-hId-591014557%22%20id%3D%22toc-hId-591014557%22%3EObserved%20Behavior%3C%2FH4%3E%3CP%3EWe%20have%20tried%20creating%20a%20modern%20site%20using%20SharePoint%20in-built(team%20%22STS%233%22%20and%20communication%20%22SITEPAGEPUBLISHING%230%22)%20site%20collection%20template%2C%20but%20it%20creates%20a%20classic%20site.%3C%2FP%3E%3CH4%20id%3D%22toc-hId--1961142432%22%20id%3D%22toc-hId--1961142404%22%20id%3D%22toc-hId--1961142404%22%20id%3D%22toc-hId--1961142404%22%20id%3D%22toc-hId--1961142404%22%20id%3D%22toc-hId--1961142404%22%20id%3D%22toc-hId--1961142404%22%20id%3D%22toc-hId--1961142404%22%3ESteps%20to%20Reproduce%3C%2FH4%3E%3CP%3EWe%20are%20using%20the%20below%20project%20Reference%20link%20for%20creating%20this%20app%3A%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2FPnP%2Ftree%2Fmaster%2FSamples%2FProvisioning.SiteCol.OnPrem%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FSharePoint%2FPnP%2Ftree%2Fmaster%2FSamples%2FProvisioning.SiteCol.OnPrem%3C%2FA%3E%3C%2FP%3E%3CH5%20id%3D%22toc-hId--414845602%22%20id%3D%22toc-hId--414845574%22%20id%3D%22toc-hId--414845574%22%20id%3D%22toc-hId--414845574%22%20id%3D%22toc-hId--414845574%22%20id%3D%22toc-hId--414845574%22%20id%3D%22toc-hId--414845574%22%20id%3D%22toc-hId--414845574%22%3ESource%20code%20for%20the%20code%20snippet%3C%2FH5%3E%3CDIV%20class%3D%22highlight%20highlight-source-cs%22%3E%3CPRE%3E%20%3CSPAN%20class%3D%22pl-k%22%3Eprivate%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-k%22%3Estring%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-en%22%3ECreateSiteCollection%3C%2FSPAN%3E(%3CSPAN%20class%3D%22pl-k%22%3Estring%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3EhostWebUrl%3C%2FSPAN%3E%2C%20%3CSPAN%20class%3D%22pl-k%22%3Estring%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3Eurl%3C%2FSPAN%3E%2C%20%3CSPAN%20class%3D%22pl-k%22%3Estring%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3Etemplate%3C%2FSPAN%3E%2C%20%3CSPAN%20class%3D%22pl-k%22%3Estring%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3Etitle%3C%2FSPAN%3E%2C%20%3CSPAN%20class%3D%22pl-k%22%3Estring%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3EadminAccount%3C%2FSPAN%3E)%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-c%22%3E%2F%2F%20Resolve%20root%20site%20collection%20URL%20from%20host%20web.%20We%20assume%20that%20this%20has%20been%20set%20as%20the%20%22TenantAdminSite%22%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-k%22%3Estring%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3ErootSiteUrl%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-k%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3EhostWebUrl%3C%2FSPAN%3E.%3CSPAN%20class%3D%22pl-en%22%3ESubstring%3C%2FSPAN%3E(%3CSPAN%20class%3D%22pl-c1%22%3E0%3C%2FSPAN%3E%2C%20%3CSPAN%20class%3D%22pl-c1%22%3E8%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-k%22%3E%2B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3EhostWebUrl%3C%2FSPAN%3E.%3CSPAN%20class%3D%22pl-en%22%3ESubstring%3C%2FSPAN%3E(%3CSPAN%20class%3D%22pl-c1%22%3E8%3C%2FSPAN%3E).%3CSPAN%20class%3D%22pl-en%22%3EIndexOf%3C%2FSPAN%3E(%3CSPAN%20class%3D%22pl-s%22%3E%3CSPAN%20class%3D%22pl-pds%22%3E%22%3C%2FSPAN%3E%2F%3CSPAN%20class%3D%22pl-pds%22%3E%22%3C%2FSPAN%3E%3C%2FSPAN%3E))%3B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-c%22%3E%2F%2FResolve%20URL%20for%20the%20new%20site%20collection%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-k%22%3Evar%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3EwebUrl%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-k%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3Estring%3C%2FSPAN%3E.%3CSPAN%20class%3D%22pl-en%22%3EFormat%3C%2FSPAN%3E(%3CSPAN%20class%3D%22pl-s%22%3E%3CSPAN%20class%3D%22pl-pds%22%3E%22%3C%2FSPAN%3E%7B0%7D%2Fsites%2F%7B1%7D%3CSPAN%20class%3D%22pl-pds%22%3E%22%3C%2FSPAN%3E%3C%2FSPAN%3E%2C%20%3CSPAN%20class%3D%22pl-smi%22%3ErootSiteUrl%3C%2FSPAN%3E%2C%20%3CSPAN%20class%3D%22pl-smi%22%3Eurl%3C%2FSPAN%3E)%3B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-c%22%3E%2F%2F%20Notice%20that%20this%20assumes%20that%20AdministrationSiteType%20as%20been%20set%20as%20TenantAdministration%20for%20root%20site%20collection%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-c%22%3E%2F%2F%20If%20this%20tenant%20admin%20URI%20is%20pointing%20to%20site%20collection%20which%20is%20host%20named%20site%20collection%2C%20code%20does%20create%20host%20named%20site%20collection%20as%20well%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-k%22%3Evar%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3EtenantAdminUri%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-k%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-k%22%3Enew%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-en%22%3EUri%3C%2FSPAN%3E(%3CSPAN%20class%3D%22pl-smi%22%3ErootSiteUrl%3C%2FSPAN%3E)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-k%22%3Estring%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3Erealm%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-k%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3ETokenHelper%3C%2FSPAN%3E.%3CSPAN%20class%3D%22pl-en%22%3EGetRealmFromTargetUrl%3C%2FSPAN%3E(%3CSPAN%20class%3D%22pl-smi%22%3EtenantAdminUri%3C%2FSPAN%3E)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-k%22%3Evar%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3Etoken%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-k%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3ETokenHelper%3C%2FSPAN%3E.%3CSPAN%20class%3D%22pl-en%22%3EGetAppOnlyAccessToken%3C%2FSPAN%3E(%3CSPAN%20class%3D%22pl-smi%22%3ETokenHelper%3C%2FSPAN%3E.%3CSPAN%20class%3D%22pl-smi%22%3ESharePointPrincipal%3C%2FSPAN%3E%2C%20%3CSPAN%20class%3D%22pl-smi%22%3EtenantAdminUri%3C%2FSPAN%3E.%3CSPAN%20class%3D%22pl-smi%22%3EAuthority%3C%2FSPAN%3E%2C%20%3CSPAN%20class%3D%22pl-smi%22%3Erealm%3C%2FSPAN%3E).%3CSPAN%20class%3D%22pl-smi%22%3EAccessToken%3C%2FSPAN%3E%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-k%22%3Eusing%3C%2FSPAN%3E%20(%3CSPAN%20class%3D%22pl-k%22%3Evar%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3EadminContext%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-k%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3ETokenHelper%3C%2FSPAN%3E.%3CSPAN%20class%3D%22pl-en%22%3EGetClientContextWithAccessToken%3C%2FSPAN%3E(%3CSPAN%20class%3D%22pl-smi%22%3EtenantAdminUri%3C%2FSPAN%3E.%3CSPAN%20class%3D%22pl-en%22%3EToString%3C%2FSPAN%3E()%2C%20%3CSPAN%20class%3D%22pl-smi%22%3Etoken%3C%2FSPAN%3E))%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-k%22%3Evar%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3Etenant%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-k%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-k%22%3Enew%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-en%22%3ETenant%3C%2FSPAN%3E(%3CSPAN%20class%3D%22pl-smi%22%3EadminContext%3C%2FSPAN%3E)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-k%22%3Evar%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3Eproperties%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-k%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-k%22%3Enew%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-en%22%3ESiteCreationProperties%3C%2FSPAN%3E()%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-smi%22%3EUrl%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-k%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3EwebUrl%3C%2FSPAN%3E%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-smi%22%3EOwner%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-k%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3EadminAccount%3C%2FSPAN%3E%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-smi%22%3ETitle%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-k%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3Etitle%3C%2FSPAN%3E%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-smi%22%3ETemplate%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-k%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3Etemplate%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%3B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-c%22%3E%2F%2Fstart%20the%20SPO%20operation%20to%20create%20the%20site%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-en%22%3ESpoOperation%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3Eop%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-k%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3Etenant%3C%2FSPAN%3E.%3CSPAN%20class%3D%22pl-en%22%3ECreateSite%3C%2FSPAN%3E(%3CSPAN%20class%3D%22pl-smi%22%3Eproperties%3C%2FSPAN%3E)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-smi%22%3EadminContext%3C%2FSPAN%3E.%3CSPAN%20class%3D%22pl-en%22%3ELoad%3C%2FSPAN%3E(%3CSPAN%20class%3D%22pl-smi%22%3Eop%3C%2FSPAN%3E%2C%20%3CSPAN%20class%3D%22pl-smi%22%3Ei%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-k%22%3E%3D%26gt%3B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3Ei%3C%2FSPAN%3E.%3CSPAN%20class%3D%22pl-smi%22%3EIsComplete%3C%2FSPAN%3E)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-smi%22%3EadminContext%3C%2FSPAN%3E.%3CSPAN%20class%3D%22pl-en%22%3EExecuteQuery%3C%2FSPAN%3E()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-c%22%3E%2F%2F%20Set%20theme%20for%20the%20new%20site%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-en%22%3ESetThemeToNewSite%3C%2FSPAN%3E(%3CSPAN%20class%3D%22pl-smi%22%3EwebUrl%3C%2FSPAN%3E)%3B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-c%22%3E%2F%2F%20Return%20URL%20for%20redirection%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pl-k%22%3Ereturn%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-smi%22%3EwebUrl%3C%2FSPAN%3E%3B%0A%20%20%20%20%20%20%20%20%7D%3C%2FPRE%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-764109%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Emodern%20site%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%202019%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-764232%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20provision%20modern%20site%20using%20provider%20hosted%20app%20in%20SharePoint%202019%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-764232%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F71188%22%20target%3D%22_blank%22%3E%40ArvindKumar%20Mepani%3C%2FA%3Ewhat%20version%20of%20%3CSPAN%3EMicrosoft.Online.SharePoint.Client.Tenant.dll%3C%2FSPAN%3Eare%20you%20referencing%20in%20your%20project%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20just%20created%20a%20simple%20Console%20Application%20to%20see%20if%20I%20was%20able%20to%20create%20both%20a%20modern%20team%20site%20and%20a%20communication%20site%20collection%20in%20my%20environment%20and%20it%20gives%20me%20the%20modern%20sites%20as%20expected.%20I'm%20basically%20using%20the%20same%20code%20as%20yours%20except%20that%20I%20don't%20call%20SetThemeToNewSite%20in%20the%20end.%20Could%20it%20be%20this%20method%20is%20causing%20your%20site%20to%20revert%20back%20to%20classic%20experience%20somehow%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20using%20version%2016.1.9021.1200%20(latest%20version%20of%20Microsoft.SharePointOnline.CSOM%20NuGet%20package).%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-767301%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20provision%20modern%20site%20using%20provider%20hosted%20app%20in%20SharePoint%202019%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-767301%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20for%20your%20help%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1803%22%20target%3D%22_blank%22%3E%40Paul%20Pascha%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20version%20of%20Microsoft.Online.SharePoint.Client.Tenant.dll%20is%2016.1.9021.1200.%3C%2FP%3E%3CP%3EI%20am%20also%20able%20to%20create%20a%20modern%20site%20collection%20using%20a%20console%20app.%20But%20when%20I%20tried%20creating%20modern%20site%20collection%20with%20the%20same%20code%20using%20provider%20hosted%20app%2C%20it%20always%20creates%20classic%20site%20only.%3C%2FP%3E%3CP%3EI%20have%20removed%20SetThemeToNewSite%20method%20as%20well.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-769044%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20provision%20modern%20site%20using%20provider%20hosted%20app%20in%20SharePoint%202019%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-769044%22%20slang%3D%22en-US%22%3EWeird!%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20Console%20App%20I%20wrote%20is%20technically%20a%20Provider-hosted%20add-in%20(using%20app%20only%20authentication)%20so%20I%20can't%20really%20see%20the%20difference%20compared%20to%20a%20typical%20web-based%20Provider-hosted%20add-in.%3CBR%20%2F%3E%3CBR%20%2F%3EI've%20checked%20the%20CU%20level%20of%20my%20Farm%20which%20is%20slightly%20higher%20than%20yours%2C%20(May%202019%20CU).%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-769327%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20provision%20modern%20site%20using%20provider%20hosted%20app%20in%20SharePoint%202019%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-769327%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1803%22%20target%3D%22_blank%22%3E%40Paul%20Pascha%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3EWe%20have%20updated%20the%20CU%20version%20(May%202019%20CU)%20but%20still%20we%20are%20not%20able%20to%20create%20modern%20site%20collection%20using%20provider%20hosted%20app.%3C%2FP%3E%3CP%3ENote%3A%20we%20are%20not%20using%20App%20only%20authentication.%20We%20have%20added%20GetS2SAccessTokenWithWindowsIdentity%20for%20the%20authentication%20as%20per%20our%20requirement.%3C%2FP%3E%3CP%3EWe%20are%20using%20following%20code%20snippet%20is%20for%20authentication%3A%3C%2FP%3E%3CP%3ETokenHelper.GetS2SAccessTokenWithWindowsIdentity(tenantAdminUri%2C%20HttpContext.Current.User.Identity%20as%20WindowsIdentity)%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-770924%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20provision%20modern%20site%20using%20provider%20hosted%20app%20in%20SharePoint%202019%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-770924%22%20slang%3D%22en-US%22%3EIs%20it%20possible%20for%20you%20to%20share%20your%20full%20app%3F%20I%20can%20then%20try%20installing%20and%20running%20on%20my%20environment%20to%20see%20what%20happens%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

We are trying to create a modern site from the provider hosted app in SharePoint 2019.
We have tried creating a modern site using SharePoint in-built(team "STS#3" and communication "SITEPAGEPUBLISHING#0") site collection template, but it creates a classic site. Also, we have tried creating classic team/communication site and added a modern page in that and saved that site as a template. Taking base as that template, we tried creating a modern site, but here also it creates a classic site only.

Environment

[x] SharePoint 2019

Build Name: SharePoint Server 2019 RTM

CU Version: 16.0.10337.12109

Expected or Desired Behavior

We have tried creating a modern site using SharePoint in-built(team "STS#3" and communication "SITEPAGEPUBLISHING#0") site collection template, It should create a modern site.

Observed Behavior

We have tried creating a modern site using SharePoint in-built(team "STS#3" and communication "SITEPAGEPUBLISHING#0") site collection template, but it creates a classic site.

Steps to Reproduce

We are using the below project Reference link for creating this app: https://github.com/SharePoint/PnP/tree/master/Samples/Provisioning.SiteCol.OnPrem

Source code for the code snippet
 private string CreateSiteCollection(string hostWebUrl, string url, string template, string title, string adminAccount)
        {
            // Resolve root site collection URL from host web. We assume that this has been set as the "TenantAdminSite"
            string rootSiteUrl = hostWebUrl.Substring(0, 8 + hostWebUrl.Substring(8).IndexOf("/"));

            //Resolve URL for the new site collection
            var webUrl = string.Format("{0}/sites/{1}", rootSiteUrl, url);

            // Notice that this assumes that AdministrationSiteType as been set as TenantAdministration for root site collection
            // If this tenant admin URI is pointing to site collection which is host named site collection, code does create host named site collection as well
            var tenantAdminUri = new Uri(rootSiteUrl);
            string realm = TokenHelper.GetRealmFromTargetUrl(tenantAdminUri);
            var token = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, tenantAdminUri.Authority, realm).AccessToken;
            using (var adminContext = TokenHelper.GetClientContextWithAccessToken(tenantAdminUri.ToString(), token))
            {
                var tenant = new Tenant(adminContext);
                var properties = new SiteCreationProperties()
                {
                    Url = webUrl,
                    Owner = adminAccount,
                    Title = title,
                    Template = template
                };

                //start the SPO operation to create the site
                SpoOperation op = tenant.CreateSite(properties);
                adminContext.Load(op, i => i.IsComplete);
                adminContext.ExecuteQuery();
            }

            // Set theme for the new site
            SetThemeToNewSite(webUrl);

            // Return URL for redirection
            return webUrl;
        }
5 Replies
Highlighted

@ArvindKumar Mepaniwhat version of Microsoft.Online.SharePoint.Client.Tenant.dll are you referencing in your project?

 

I've just created a simple Console Application to see if I was able to create both a modern team site and a communication site collection in my environment and it gives me the modern sites as expected. I'm basically using the same code as yours except that I don't call SetThemeToNewSite in the end. Could it be this method is causing your site to revert back to classic experience somehow?

 

I'm using version 16.1.9021.1200 (latest version of Microsoft.SharePointOnline.CSOM NuGet package). 

Highlighted

Thanks for your help, @Paul Pascha 

The version of Microsoft.Online.SharePoint.Client.Tenant.dll is 16.1.9021.1200.

I am also able to create a modern site collection using a console app. But when I tried creating modern site collection with the same code using provider hosted app, it always creates classic site only.

I have removed SetThemeToNewSite method as well.

Highlighted
Weird!

The Console App I wrote is technically a Provider-hosted add-in (using app only authentication) so I can't really see the difference compared to a typical web-based Provider-hosted add-in.

I've checked the CU level of my Farm which is slightly higher than yours, (May 2019 CU).
Highlighted

 

Hi @Paul Pascha ,

We have updated the CU version (May 2019 CU) but still we are not able to create modern site collection using provider hosted app.

Note: we are not using App only authentication. We have added GetS2SAccessTokenWithWindowsIdentity for the authentication as per our requirement.

We are using following code snippet is for authentication:

TokenHelper.GetS2SAccessTokenWithWindowsIdentity(tenantAdminUri, HttpContext.Current.User.Identity as WindowsIdentity);

Highlighted
Is it possible for you to share your full app? I can then try installing and running on my environment to see what happens