Enable Site Collection App Catalog For Particular Site Collection Level Solution/Features

In this article, we will learn how to enable site collection app catalog. By enabling the site collection level app catalog (not the tenant), we can deploy/install SharePoint AddIn/SPFx solutions at the site collection level. Consider this like sandbox solution, as a component is only deployed and is installed on the site collection and not available for other site collections.
 

Why do we need a Site Collection App Catalog?

 
There are times and cases when we, as a developer, have to build a solution which is very much specific to a particular project or application. This solution demands a very determined approach to solving a specific problem which is not required for other site collections of your tenant. Below are some of the reasons why we need a site collection app catalog. 
  • Provide isolated and focused solution/web part for a particular project.
  • Tenant level App/Add-in is visible to all site collection under a tenant. Risk of installing the app in other site collections is nullified for which solution is not required.
  • Provides controls to Site collection admins to manage solutions specific on site collection.
  • No need to provide access to site collection admins to deploy the app on the tenant.
  • Saves times and faster deployment methodology.

How to enable site collection app catalog?

 
Notes
  • Enabling site collection app catalog for the particular site requires tenant level administrator access.
  • This is a one-time activity to be done by tenant admins.  

Option 1 - Using SharePoint Online Management Shell.

 
Download and install, if not already, SharePoint Online Management Shell from this link.
 
Once installed, open SharePoint Online Management Shell.
 
Connect to the Tenant.
  1. Connect-SPOService -Url https://wayneenterprise-admin.sharepoint.com -credential [email protected]
Connect to the particular site and run Add-SPOSiteCollectionAppCatalog.
  1. # get a reference to the site collection where the  
  2. # site collection app catalog should be created  
  3. $site = Get-SPOSite https://wayneenterprise.sharepoint.com/sites/justiceleague
  4.  
  5. # create site collection app catalog  
  6. Add-SPOSiteCollectionAppCatalog -Site $site  
Once you go to the site collection, you will see the app for SharePoint library which can be used to deploy the app.
 

Option 1 - Using Office365 CLI

 
We can also use PnP Office365 CLI.  See this ummary of what Office 365 CLI is: (reference link)
 
Using the Office 365 CLI, you can manage your Microsoft Office 365 tenant and SharePoint Framework projects on any platform. No matter if you are on Windows, macOS or Linux, using Bash, Cmder or PowerShell, using the Office 365 CLI you can configure Office 365, manage SharePoint Framework projects and build automation scripts. 
  
Install Office 365 CLI (if not already installed.). Office 365 comes as NPM package which can be installed from Node JS prompt using below command,
  1. npm i -g @pnp/office365-cli  
Go to Office 365  CLI. type below command in Node JS command prompt.
  1. office365  
Now we are in office 365 CLI and can run office 365 CLI commands.
 
Enable Site Collection App Catalog For Particular Site Collection Level Solution/Features
 
The next step is to log into Office 365 tenant.
  1. spo login https://wayneenterprise-admin.sharepoint.com   
It will give us the below message.
 
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code SAVEGOTHAM to authenticate. 
 
Enable Site Collection App Catalog For Particular Site Collection Level Solution/Features
 
Open  https://microsoft.com/devicelogin in the browser - Enter the code and click "Next".
 
Enable Site Collection App Catalog For Particular Site Collection Level Solution/Features
 
Select the account or sign in with a new account,
 
Enable Site Collection App Catalog For Particular Site Collection Level Solution/Features
 
Click Accept 
 
Enable Site Collection App Catalog For Particular Site Collection Level Solution/Features
 
We will get the below success message, close window. 
 
Enable Site Collection App Catalog For Particular Site Collection Level Solution/Features
 
Go back to Node JS command prompt, run below command to enable app catalog on the particular site collection. 
  1. spo site appcatalog add --url https://wayneenterprise.sharepoint.com/sites/justiceleague  
If successful, we can go to a particular site and see that the App for SharePoint library should be created.
 
Enable Site Collection App Catalog For Particular Site Collection Level Solution/Features
 
Now we can directly deploy or App/Add-In or SPFx solution(*.sppkg) directly on the site collection. Deployment and installation of the app is similar to what we do for tenant app catalog.
 

How to disable the site collection app catalog?

 
Using Powershell
  1. # get a reference to the site collection in which  
  2. # the site collection app catalog should be disabled  
  3. $site = Get-SPOSite https://wayneenterprise.sharepoint.com/sites/justiceleague  
  4.  
  5. # disable the site collection app catalog  
  6. Remove-SPOSiteCollectionAppCatalog -Site $site  
Using Office 365 CLI
  1. spo site appcatalog remove --url https://wayneenterprise.sharepoint.com/sites/justiceleague  

Conclusion

 
In this article, we have learned how to enable app catalog on the site collection level using PowerShell and Office 365 CLI.
 
Thanks for reading.