32,469 total views, 7 views today
How to deploy SPFx solution in SharePoint online (site collection scoped app catalog) – as far as SharePoint is concerned, there are many hidden URLs, features are available both in SharePoint on pre-mise as well as SharePoint Online those actually will be hidden from the users – generally Power User access those hidden link by directly putting the URL into the browser or by activating some feature using the PowerShell or PnP PowerShell command. In this article, we will learn about how to deploy an SPFx (SharePoint Framework) solution in a particular site collection scope.
The thought behind the main topic is – as far as SharePoint Online is concerned, there is only one app catalog site collection in the tenant (at least this was my understanding) and per tenant, we can have only one tenant-level app catalog site collection. However, if we want to deploy the SPFx (SharePoint Framework) solution in a particular site collection scope, how to do it? Well, in this article we will learn about how to deploy an SPFx (SharePoint Framework) solution in a particular site collection scope. I have written an article on how to create an app catalog site collection at the tenant level – please read it from here – Create app catalog site in SharePoint online step by step
As per Microsoft about app catalog site collection:
“You can have only one App Catalog site collection for your organization, and you only need to create it once.”
I think I am not convinced about the above Microsoft statement as we could create an app catalog site collection for each individual site collection.
Key-Highlights: Deploy SPFx solution in SharePoint online (Site collection scoped app catalog)
- Challenges in tenant-level app catalog deployment scope
- How to overcome the above challenge or deploy the SPFx solution in site collection scope only?
- Enable or add the app catalog feature in the site collection scope using the PowerShell script
Challenges in tenant-level app catalog deployment scope (site collection scoped app catalog)
If you have a SharePoint Online tenant which is used for development, test, and production purpose. Then, you are developing an SPFx solution for your client which is in progress (the functionality has not yet been completed) and in between a couple of times, you have deployed to the tenant level app catalog site collection for your testing purpose – you know what will happen now? This underdevelopment web part or SPFx solution will be available across the tenant from each site – behind the end-users will not get know about this, so they just try to add this under development web part into their pages since it will display in the web part gallery but in reality, this web part will not function – as a result, this will lead to customer dissatisfaction over the use of SharePoint Online – they will just think and comment “SharePoint is not working”.
The above scenario is one of the examples of having tenant-level app catalog scope enabled, however, there are many disadvantages to this.
How to overcome the above challenge or deploy the SPFx solution in SharePoint Online site collection scope only?
In order to overcome the above issue, we have to deploy the SPFx web part or solution in the site collection scope only – now we will learn how to deploy the SPFx solution to the site collection scope only.
We can activate the “appcatalog” for any site collection – the hidden formula is, that we just need to append the URL with the “appcatalog” text, I mean we need to add the “appcatalog” text after the site name.
For example
"https://globalsharepoint2020.sharepoint.com/sites/TestCommSite2/appcatalog" - here before the '/appcatalog' is my site URL.
Now, let’s access the above URL, we will see the below “404 NOT FOUND” because we are trying to access the “appcatalog” site collection URL but the “appcatalog” has not been enabled yet in this site collection.

Now, we will execute the below PowerShell script to enable the ‘appcatalog’ in the site collection scope only.
Enable or add the app catalog feature in the site collection scope using the PowerShell script (site collection scoped app catalog)
Using the below PowerShell script we can enable or add the app catalog feature in the site collection scope:
####The below script will activate or remove app catalog site collection in the site collection level only. cls $PSshell = Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorVariable err -ErrorAction SilentlyContinue if($PSshell -eq $null) { Add-PSSnapin "Microsoft.SharePoint.PowerShell" } $fileName = "Adding-Removing app catalog in SPO site collection scope" #'yyyyMMddhhmm yyyyMMdd $enddate = (Get-Date).tostring("yyyyMMddhhmmss") #$filename = $enddate + '_VMReport.doc' $logFileName = $fileName +"_"+ $enddate+"_Log.txt" $invocation = (Get-Variable MyInvocation).Value $directoryPath = Split-Path $invocation.MyCommand.Path $directoryPathForLog=$directoryPath+"\"+"LogFiles" if(!(Test-Path -path $directoryPathForLog)) { New-Item -ItemType directory -Path $directoryPathForLog #Write-Host "Please Provide Proper Log Path" -ForegroundColor Red } #$logPath = $directoryPath + "\" + $logFileName $logPath = $directoryPathForLog + "\" + $logFileName $isLogFileCreated = $False function Write-Log([string]$logMsg) { if(!$isLogFileCreated){ Write-Host "Creating Log File..." if(!(Test-Path -path $directoryPath)) { Write-Host "Please Provide Proper Log Path" -ForegroundColor Red } else { $script:isLogFileCreated = $True Write-Host "Log File ($logFileName) Created..." [string]$logMessage = [System.String]::Format("[$(Get-Date)] - {0}", $logMsg) Add-Content -Path $logPath -Value $logMessage } } else { [string]$logMessage = [System.String]::Format("[$(Get-Date)] - {0}", $logMsg) Add-Content -Path $logPath -Value $logMessage } } ########################Adding-Removing app catalog site collection in Sharepoint Online site collection scope only############################## #Paramaters area $adminSiteURL="https://globalsharepoint2020-admin.sharepoint.com" #your admin center URL $siteURL="https://globalsharepoint2020.sharepoint.com/sites/TestCommSite2" #Your site collection URL $userName = "YourSPOOnlineUser@yourtenant.com" $passWord = "Your_SPO_Password" $encPassWord = convertto-securestring -String $passWord -AsPlainText -Force $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $userName, $encPassWord #Paramaters area - Ends Try { Connect-SPOService -Url $adminSiteURL -Credential $cred $site = Get-SPOSite $siteURL ################Adding app catalog in site collection scope ############## #The app catalog site collection is being enabled in site collection scope. Write-host -f Yellow "Creating site collection app catalog in: "$SiteURL Add-SPOSiteCollectionAppCatalog -Site $site Write-host -f Green "Created site collection app catalog in!" $SiteURL ################Adding app catalog in site collection scope - ends here #### ############Disabling the site collection app catalog####################### #The app catalog site collection is being disabled in site collection scope. Write-host -f Yellow "Disabling site collection app catalog in: "$SiteURL #Remove-SPOSiteCollectionAppCatalog -Site $site Write-host -f Yellow "Disabled site collection app catalog in: "$SiteURL ############Disabling the site collection app catalog - ends here############# } Catch { $ErrorMessage = $_.Exception.Message +"in adding or removing app catalog site collection in site collection scope only!:" Write-Host $ErrorMessage -BackgroundColor Red Write-Log $ErrorMessage } ########################Adding-Removing app catalog site collection in Sharepoint Online site collection scope only - Ends here ##############################
After executing the above PowerShell script, let’s browse the same below URL:
"https://globalsharepoint2020.sharepoint.com/sites/TestCommSite2/appcatalog"
We can see that the ‘AppCatalog’ URL is accessible now, and also we could see the “Apps for SharePoint” library is visible where we have to upload the SPFx .sppkg file.

Summary: Deploy SPFx solution in SharePoint online (site collection scoped app catalog)
Thus, in this article, we have learned how to deploy the SPFx framework solution to the SharePoint site collection scope only. We can summarize our learning as below:
- Enable or add the app catalog feature in the site collection scope using the PowerShell script.
- How to deploy the SPFx framework solution to SharePoint site collection scope only.
- The disadvantage of tenant-level SPFx deployment scope.
- How to add app catalog site collection using the “Add-SPOSiteCollectionAppCatalog” PowerShell command
- How to remove app catalog site collection using the “Remove-SPOSiteCollectionAppCatalog” PowerShell command
See Also: Deploy SPFx solution in SharePoint online (site collection scoped app catalog)
You may also like the following SharePoint PowerShell tutorials:
- SharePoint Online: Remove custom app using PnP PowerShell
- Office 365: How to create content type in SharePoint Online using PowerShell?
- Office 365: How to create document library in SharePoint Online using PowerShell?
- Export SharePoint user information list to CSV(Excel) file using PowerShell
- How to fix “The term ‘Get-MsolUser’ is not recognized as the name of a cmdlet”
- How to fix the “The term ‘Get-SPWeb’ is not recognized as the name of a cmdlet, function” PowerShell error
- How to hide quick launch menu in SharePoint online using PnP PowerShell
- Edit user Permission is greyed Out SharePoint Online
- Get workflow inventory from SharePoint online using PowerShell CSOM
- Create a modern team site using PnP PowerShell in SharePoint
- In 2 steps convert a classic SharePoint page to modern using PnP
- SharePoint Online: Delete All Files from document library for the given date – PowerShell CSOM
- Create SharePoint online list using PnP provisioning template
- SharePoint Automation: PowerShell script to get remote server information
- Office 365: Retrieve hub sites and associated sites using PnP Powershell
- SharePoint Online Automation – O365 – Upload files to document library using PowerShell CSOM
- SharePoint Online Automation – O365 – Create multiple items in a list using PowerShell CSOM
- SharePoint Online Automation – O365 – Update document library metadata using PowerShell CSOM
- Manage apps using the Apps site
Hope you have enjoyed reading this article and helped you. If you would like to appreciate our efforts, please write to the below comment section and do share this with your friends and colleagues. 🙂