DEV Community

Coding Bugs
Coding Bugs

Posted on

Tip on adding a Site Collection as an App Catalog

For all those who work with SharePoint Online and use PowerShell, I think this article may be of interest to you.

Alt Text

If you are working on a project in which you have to automate the deployments of the different containers and elements of which it is composed, I will tell you that you are in a good line, from my point of view.

If you are also automating the upload of solutions to the app catalog, then you are taking automation to a new level. And, at this point, this is where this article comes in. Perhaps you know of the existence of the SharePoint Online app catalog where solutions with new functionalities can be deployed globally to the tenant. However, there is also the possibility of creating app catalogs in each of the site collections and, thus, improving the governance of the solutions to be deployed.

Alt Text

A comparison between both models can be found in this article with a very complete list of pros and cons, https://chuvash.eu/2019/12/11/site-collection-app-catalog-vs-tenant-app-catalog

On the other hand, the official Microsoft information about this can be found at the following link, https://docs.microsoft.com/en-us/sharepoint/dev/general-development/site-collection-app-catalog

But my article is not about whether to use one or the other since it is none of our business. What I want to do is help you not to waste your time as I have done configuring a site collection as an app catalog using PowerShell commands.

If you use the standard SharePoint Online commands, https://docs.microsoft.com/en-us/powershell/module/sharepoint-online/add-spositecollectionappcatalog?view=sharepoint-ps, it is very easy to apply it, just invoke the command and pass the site collection or its URL, the nuance is not important.

If you use the PnP commands, https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/add-pnpsitecollectionappcatalog?view=sharepoint-ps, it continues indicating the same and using the same parameters.

The truth is that it does not matter if you use one set of commands or another, the result will be the same. The important thing is where you invoke the command from, and by place, I mean the site collection that you are going to connect to in the first place to invoke that command. If you use a connection to the site collection where you are creating all those lists, libraries, etc., and you want to activate it as an application catalog, it will give you a forbidden error, specifically, 403.

Alt Text

The only way to do that is if you are connected to the SharePoint administration site collection, the famous "https://#tenant-name#-admin.sharepoint.com". If not, you will not be able to activate it in any site collection.

Keep this in mind whenever you do any operation of this type and take a good look at the connection you are using, it will be very important to know where you are executing the PowerShell commands.

I hope it has been useful.

Discussion (0)