This is the 4th post of the article series regarding service applications
- Part 1 : Service application architecture – Basic Concepts
- Part 2 : How logical components of service applications map to physical components
- Part 3 : How to plan Service Applications in SharePoint 2013
- Part 4 : Change application pool of an existing service application
As I mentioned in a previous post, If we create a new service application an application in IIS is also created. That allows us to isolate service applications by providing different application pools. In this article I will show how to assign a new application pool to an existing service application.
Can we manually create an application pool with a proper identity in IIS and assign it to the service application ? It is the wrong way of assigning the application pool
The wrong way
To demonstrate above fact I created a new Managed Metadata Service application and associated it with an existing application pool named MMS2 using central administration.
Then I’ll go to IIS Manager and create a new application pool manually and associate it with our service application as below
Although IIS allows us to associate application with new application pool, SharePoint does not know the change. To show that we will use following PowerShell commands.
- $app = Get-SPMetadataServiceApplication -Identity 796cb0d5-b8cf-4e0c-a03b-1d8cc285efe3
- $app.ApplicationPool
Following is the result I got
To stress the point further, I will stop the “Managed Metadata Web Service” in services on this server section. Then all Managed Metadata Service related applications in IIS will be deleted. Once I start the service again those applications will be recreated in IIS. As you can see the application pool of the service application is reverted back to MMS12 (with it’s Guid) and no longer “MMS2AppPool”
The correct way
The first thing to not is that, service applications need to be associated with an instance of SPServiceApplicationPool. Following is the way to do that.
- #Create new application pool
- $managedAccount = Get-SPManagedAccount -Identity "dev\spserviceapp"
- $servicePppPool = New-SPServiceApplicationPool -Name MetadataApplicationPool -Account $managedAccount
- #Assign application pool to service application
- $app = Get-SPMetadataServiceApplication -Identity 796cb0d5-b8cf-4e0c-a03b-1d8cc285efe3
- $app.ApplicationPool = $servicePppPool
- $app.Update()
Following is the result I got
Now it doesn’t matter if I stop and start the service instance, the application pool remains the same.