One of the benefits of SharePoint add-ins is that they run in their own isolated domain, unlike the farm solutions that shares the process thread, resulting in performance risks. So, one of the prerequisites of SharePoint add-ins is that a domain has to be configured in the DNS. We can add the domain by going to the DNS configuration tool.
As part of security, while creating the domain for the app, it should not be a sub-domain of an existing domain. Say, if we have a domain of the name SharePoint2016.com, instead of creating Apps.SharePoint2016.com, we should be creating a domain of the format SharePoint2016Apps.com.
When an add-in is provisioned, it creates a unique domain name, like 23131123asas.SharePoint2016Apps.com, where 23131123asas is the unique identifier for the app. In order for the DNS domain to support these kinds of unique name, we will also have to set up a wildcard Canonical Name (CNAME).The process of setting up the domain can be summed up as,
- Create Forward Lookup Zone
- Add CNAME
- Create Subscription settings service application
- Configure App URL in Central Admin
Create Forward Lookup Zone
As the first step, let’s create a Forward Lookup Zone. In order to do this, one has to be a domain administrator.
From the DNS Manager, right click ‘Forward Lookup Zones’ and click on ‘New Zone’.
This will start the New Zone Wizard. Click on Next.
Select the zone type as ‘Primary’ and click on Next.
In the Active Directory Zone Replication Scope page, select the appropriate replication method. By default, it is set as : ‘To all DNS servers running on domain controllers in this domain’.
This is the main stage where we get to specify the App Domain Name. Specify the name and click on Next.
Select the required dynamic update option. For Active Directory integrated zones, select ‘Allow only secure dynamic updates’.
Thus, we have completed the creation of the Forward Lookup Zone.
The new zone has come up in the available list of zones.
Add CNAME
Now, we can add a wildcard CNAME for the newly created domain. Right click the newly created zone and select ‘New Alias(CNAME)’.
Specify ‘*’ as the wildcard alias and this will automatically add ‘*.NewlyCreatedDomainName’ as the fully qualified domain name.
Now, we have to specify the FQDN for the target host. Select "Browse" and go to the Forward Lookup Zone and double click it. Double click the domain that hosts the SharePoint sites. From there, select the record “same as parent folder” and click OK.
This will work okay in case of a single server environment. However, in case of a multi-server farm, ensure that you point to the DNS Record of the web server.
This completes the setting up of DNS entry. In order to ensure that the newly created domain name is working, we can try pinging it. If it returns an IP with successful delivery of data packets, we can be sure that the wildcard for the domain name was set up successfully.
Create App Management Service Application and Subscription Settings Service Application
Once we have set up the DNS entry, we have to set up the subscription settings service applications and the App Management Service Application. App Management Service Application can be created from the Central Admin UI which is pretty straight forward.
App Management Service Application
In order to create the app management service application, select "Manage service applications" from Application Management.
Select "App Management Service".
It will open up the window where we can specify the Service Application name and database name.
Specify the app pool name and service account that will be used for the service application and click on OK.
This will start provisioning the App Management Service Application.
After some time, you will see the Service Application created and listed out.
Subscription Settings Service Application
However, in order to create Subscription settings Service Application, we have to use PowerShell. Even in SharePoint 2016, a UI alternative is not available. You can use the below PowerShell script to create the Subscription Settings Service Application.
- $account = Get-SPManagedAccount "SharePointHOL\Priyan_ManagedAcc"
- $appPool = New-SPServiceApplicationPool -Name 'Subscription App Pool' -Account $account
- $SubscriptionSvcApp = New-SPSubscriptionSettingsServiceApplication -ApplicationPool $appPool -Name 'Subscription Settings Service Application' -DatabaseName 'SubscriptionSettings_ServiceDB'
- $SubscriptionSvcproxy = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $SubscriptionSvcApp
Thus, the subscription settings service application has been created.
Configure App URL
Now, let’s configure the app URL. In order to do that, go to the Apps section in the Central Administration.
Click on Configure App URLs.
This will open up the page where we can add the app domain and app prefix.
HOLApps.com was the app domain that was created. Specify the app prefix which will come up prepended in the app URL in the browser.
In case you face the below error while saving the page, it is an indication that the Subscription Settings Service Application has some configuration issue. Try restarting it.
Summary
Thus, we have seen how to configure the environment in SharePoint Server 2016 to get started with add-in development.