SharePoint Development Practices and Techniques

  • 11/15/2013

Configuring SharePoint service applications

In SharePoint Server 2010 the concept of service applications was introduced. SharePoint contains several different service applications, and all of them provide a specific piece of functionality to your SharePoint farm if they are enabled. All service applications can be shared across web applications, and some service applications can even be shared across farms. Let’s establish the terminology first.

A service application itself is the logical container of the service. We use the term service application to describe the services architecture in SharePoint. It is also what is exposed in the Central Administration site through the Manage Service Applications page. For most service applications, there can be more than one instance of the service application in a single farm.

The service instance is the actual implementation of the service, the binaries. A service instance could include Windows Services, configuration, registry settings, timer jobs, and more. The bits that make up the service instance are deployed to every SharePoint server in the farm.

The service machine instance of a particular service application is the server or servers in the farm on which the service for that service application runs. You can check where a service is running and start or stop a service on a particular server by going to the Services On Server page in the Central Administration site. On this page, you can select a server and then start the services you want to run on that particular server. When a service runs on more than one server in the farm, software round-robin load balancing is provided by SharePoint. Not all service applications have an associated service machine instance. Most service applications can have more than one associated service machine instance, but some can only have one. Not all services you see on the Services On Server page are service machine instances of a service application.

The service application endpoint is created when you start a service. Starting the service and thus creating a service machine instance creates an Internet Information Services (IIS) virtual application in the SharePoint Web Services IIS website. The virtual application includes a Windows Communication Foundation (WCF) or .asmx web service. This web service is the service application endpoint. Each service application must have its own service application endpoint.

A service application proxy (also called service connection or service association) is a virtual link between a web application and a service application. The service application proxy also enables cross-farm services.

A proxy group is a group of service application proxies that are selected for one or more web applications. By default, all service application proxies are included in the default proxy group. When you create a web application, you can do one of the following:

  • Select the default proxy group.

  • Create a custom proxy group by selecting which service application proxies you want to link to the web application. These service application proxies will then be included in the proxy group.

The custom proxy group for one web application cannot be reused with a different web application.

There are three ways in which you can configure service applications:

  • By selecting services when you run the SharePoint Products Configuration Wizard

  • By adding services one by one on the Manage Service Applications page in SharePoint 2013 Central Administration

  • By using Windows PowerShell

It is not recommended that you use the SharePoint Product Configuration Wizard to configure service applications. Using the wizard will create the service applications with a set of default settings that might not be suitable for your environment. If you use the wizard it is also very easy (as easy as selecting a check box) to create too many service applications. You should always just create the service applications that you need in your farm. Every service application consumes a certain amount of resources, so creating a service application that you don’t need means that you are burning valuable resources on your server.

To create a service application from the Manage Service Applications page in Central Administration, you start by clicking the New button on the Manage Service Applications page, as shown in Figure 2-1. Click Managed Metadata Service to create a managed metadata service application.

Figure 2-1

Figure 2-1 The Manage Service Applications page in Central Administration

On the next page, you enter a name for the service application and for the database that will store the contents and configuration of the managed metadata service application that you are creating, as shown in Figure 2-2. In this example, the name of the service application is Managed Metadata Service Application. The name of the database is ManagedMetadata. If this is the first service application that you are creating, you will also have to create an application pool that it can use. The name of the application pool in this example is SharePoint Web Services Default. This is the same name that the wizard would have used for the application pool that it creates if you use it to create service applications. In most cases, this application pool can be used for most if not all of your service applications. The account that is used in this example is the WINGTIPTOYS\spservices account. Be aware that the account that you use as the application pool account must be a managed account. Go to the Configure Managed Accounts page in Central Administration to create a new managed account. All managed accounts should be dedicated service accounts. Selecting Add This Service Application To The Farm’s Default List means that SharePoint will add the service application to the default proxy group after you click OK.

Figure 2-3 shows the Manage Service Applications page after the managed metadata service application has been created. Creating the managed metadata service application through the Manage Service Applications page also automatically creates the managed metadata service application proxy. Most service applications automatically create their proxy when they are created through the Central Administration user interface. When Windows PowerShell is used to create the service application, you will almost always have to create the service application proxy yourself.

Figure 2-2

Figure 2-2 Creating a Managed Metadata Service Application

Figure 2-3

Figure 2-3 The Manage Service Applications page with the Managed Metadata Service Application and proxy

Some service applications start their service or services automatically, but for most service applications you will have to go into the Manage Services On Server page in Central Administration (shown in Figure 2-4). For the managed metadata service application, you will have to start the Managed Metadata Web Service on at least one server in the farm. In most development environments you will only have one SharePoint server, so you can start the service only on that server. Starting the service will also create a new IIS virtual application in the SharePoint Web Services IIS website. The name of the virtual application is a GUID, and the application will include the MetadataWebService.svc web service.

Figure 2-4

Figure 2-4 The Manage Services On Server page

Listing 2-2 shows the Windows PowerShell script that will create the service application, the application pool, and the service application proxy and that will start the managed metadata web service.

Listing 2-2 A Windows PowerShell script to configure the Managed Metadata Service Application

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction "SilentlyContinue"

$saAppPoolName = "SharePoint Web Services Default"
$appPoolUserName = "WINGTIPTOYS\spservices"

# Gets Application Pool, or creates one
$saAppPool = Get-SPServiceApplicationPool -Identity $saAppPoolName -EA 0
if($saAppPool -eq $null)
{

  Write-Host "Creating Application Pool"
  # Create Application Pool
  $saAppPoolAccount = Get-SPManagedAccount -Identity $appPoolUserName
  $saAppPool = New-SPServiceApplicationPool -Name $saAppPoolName '
    -Account $saAppPoolAccount
}

$mmsInstanceName = "MetadataWebServiceInstance"
$mmsName = "Managed Metadata Service Application"
$mmsDBName = "ManagedMetadata"

Write-Host "Creating Managed Metadata Service Application & proxy"
$mms = New-SPMetadataServiceApplication -Name $mmsName '
    -ApplicationPool $saAppPoolName -DatabaseName $mmsDBName
$proxy = New-SPMetadataServiceApplicationProxy -Name "$mmsName Proxy "'
    -ServiceApplication $mms -DefaultProxyGroup
Write-Host "Starting Managed Metadata Web Service"
Get-SPServiceInstance | where {$_.GetType().Name '
    -eq $mmsInstanceName} | Start-SPServiceInstance
Write-Host "Managed Metadata Service Application successful configured!"