Retrieving the URL of an app catalog site in SharePoint 2013

In some of my recent work with the xSharePoint resources we came up with a need to retrieve the current URL of an app catalog so that we could determine if the current settings were correct or not. The issue with this is that we found there is no out of the box cmdlet to retrieve the current app catalog URL for a specific web application, only to update the settings with Update-SPAppCatalogConfiguration. To facilitate getting the current URL we had to do a bit of digging to find where it was stored after this point, and as it turned out this was found in the properties of the app feature which is turned on within the web application object. In order to retrieve the current URL we wrote the following little script to get it:

  $WebAppUrl = "https://sharepoint1:1234"
 
 $wa = Get-SPWebApplication $WebAppUrl
 $feature = $wa.Features[[Guid]::Parse("f8bea737-255e-4758-ab82-e34bb46f5828")]
 $site = Get-SPSite $feature.Properties["__AppCatSiteId"].Value
 
 return $site.Url

There are two things to notice here:

  1. The GUID we use here is a constant, it's the ID of the feature that is responsible for flagging the app catalogs presence in a web application
  2. The property that stores the GUID of the site collection is called "__AppCatSiteId"

This allows us to retrieve the site collection and get the URL that is currently used. Remember if you want to update this that you should use the Update-SPAppCatalogConfiguration cmdlet I mentioned before as manually manipulating this feature and its properties will get you in an unsupported state pretty quickly - but you can interrogate the values that SharePoint puts here to find the current app catalog URL if you need to read it for something you are working on.

Comments

  • Anonymous
    August 20, 2017
    Is there Server side script to get the App Catalog URL? Please help
    • Anonymous
      August 20, 2017
      That example is PowerShell that is designed to run on the server - I'm not sure what you are asking? - B
      • Anonymous
        August 21, 2017
        Thank you for the quick response. I am trying to get the App Catalog URL in C#. I am trying to install an app from App Catalog when a new site is provisioned. I would like to get the AppCatalog site URL and then extract the app from "Apps for SharePoint" library
        • Anonymous
          August 21, 2017
          OK so I'm a little rusty on my C# but you should be able to do something like this using (var webApp = new SPWebApplication("http://mySharePointSite")){ var feature = webApp.Features[System.Guid.Parse("f8bea737-255e-4758-ab82-e34bb46f5828")]; var siteUrl = feature.Properties["__AppCatSiteId"].Value;}then from there do what you please with the url of that site. Like I said though, I haven't had to write server side code for SharePoint for a while so the specific code there might be a little rusty, but it should give you the rough idea of how to do it.
          • Anonymous
            August 22, 2017
            Thank you for the quick help. I was able to get App Catalog Site URL.
          • Anonymous
            August 22, 2017
            My requirement was to get the App Catalog for the current Web Application. Here is the code that I wrote:SPWebApplication webApp = web.Site.WebApplication;SPFeature feature = webApp.Features[new Guid("f8bea737-255e-4758-ab82-e34bb46f5828”)]; //GUID for App Catalog Settingsstring strAppCatalog = feature.Properties["__AppCatSiteId"].Value;SPSite siteWeb = new SPSite(new Guid(strAppCatalog);