Legacy SharePoint AddIns
The Core SDK Admin library contains APIs to enumerate the SharePoint AddIns that are installed in a site collection.
Creating Context
In this article, you'll see a lot of context
use: in this case this is a PnPContext
which was obtained via the PnPContextFactory
as explained in the overview article and shown below:
using (var context = await pnpContextFactory.CreateAsync("SiteToWorkWith"))
{
// See next chapter on how to use the PnPContext for doing SharePoint admin operations
}
PnP.Core.Admin dependency
The functionality shown in this article depends on the PnP.Core.Admin nuget package. Once the PnP.Core.Admin nuget package has been installed you can get to the SharePoint admin features via using the GetSharePointAdmin
, GetSiteCollectionAppManager
, GetTenantAppManager
and GetSiteCollectionManager
extension methods:
using (var context = await pnpContextFactory.CreateAsync("SiteToWorkWith"))
{
// Use the GetSharePointAdmin extension method on any PnPContext
// to tap into the SharePoint admin features
var url = context.GetSharePointAdmin().GetTenantAdminCenterUri();
}
Note
If your tenant is using vanity URL's then you'll need to populate the VanityUrlOptions
class and pass it to any method that allows it.
Enumerating the SharePoint AddIns installed in a site collection
SharePoint AddIns are installed in sites, enumerating them then starts from the site collection you want to get the installed SharePoint AddIns from. To do so use on of the GetSiteCollectionSharePointAddIns
methods which will return a collection of ISharePointAddIn
object instances.
var addIns = await context.GetSiteCollectionManager().GetSiteCollectionSharePointAddInsAsync();
foreach(addIn in addIns)
{
// do something with the AddIn
}
Note
SharePoint AddIns are typically installed per site, but sometimes the SharePOint AddIn can be installed in the corporate app catalog and deployed tenant wide. In the returned data you can see that by looking at the Installed...
properties versus the Current...
properties: when these are the same then the SharePoint AddIn was installed in the current site, if not then the SharePoint was installed via an app catalog and the Installed...
properties will give you information about the app catalog where the SharePoint AddIn was installed.
Uninstalling a SharePoint AddIn
Coming soon.