The managed metadata service application provides the core backend functionality for the managed metadata features in SharePoint. A SharePoint farm may contain one or more managed metadata service applications. Using multiple service applications provides the ability to isolate metadata content between web applications and also provides differing permissions.
In addition to the methods outlined in this recipe, the managed metadata service application can also be provisioned with the Farm Configuration Wizard in Central Administration when configuring the SharePoint farm for the first time.
Follow these steps to create a new managed metadata service application:
Service applications in SharePoint provide the backend web services and access to data storage used by many of the features throughout SharePoint. Multiple service applications of the same type may be used to isolate data between different web applications.
The managed metadata service application provides the web services and access to SQL data storage used by the managed metadata features on the frontend.
Granting yourself full control (administrator) access to the service application provides you with full control over managing the term sets within the service application. Some functionality in the management page for the managed metadata service application will be unavailable if you do not grant full control to yourself. In addition, other users may be added who aren't necessarily farm administrators. If a user who is not a farm administrator is granted access, they will only be able to navigate to the service applications they have access to when they browse to Central Administration.
Service applications may also be created with PowerShell or code using the server-side object model.
Follow these steps to create a new managed metadata service application using PowerShell:
New-SPServiceApplicationPool
Cmdlet to create a new application pool to run our new service application and assign it to a variable. Use an existing managed account.$pool = New-SPServiceApplicationPool "Managed Metadata Service Application Pool" -Account "domainuser"
Alternatively, the Get-SPServiceApplicationPool
Cmdlet may be used to retrieve an existing service application pool rather than creating a new one. In addition, to use a new service account rather than an existing one. The New-SPManagedAccount
Cmdlet can be used to create it. The account specified must already be registered as a managed account with SharePoint before creating the application pool.
New-SPMetadataServiceApplication
Cmdlet to create our new service application:$mms = New-SPMetadataServiceApplication -Name "Managed Metadata Service" -ApplicationPool $pool -DatabaseName "ManagedMetadata"
New-SPMetadataServiceApplicationProxy
Cmdlet to create the proxy to our new service application and add it to the default proxy group:New-SPMetadataServiceApplicationProxy –Name "Managed Metadata Service Proxy" -ServiceApplication $mms –DefaultProxyGroup
Get-SPServer
Cmdlet:(Get-SPServer servername).ServiceInstances | Where-Object { $_.TypeName -eq "Managed Metadata Web Service" } | ForEach-Object { $_.Provision() }
Portions of the server-side object model are not publicly exposed from the SharePoint assemblies. As such, we will use .NET reflection to invoke the methods necessary to create the service application, proxy, and application pool. Follow these steps to create a new managed metadata service application with code using the server-side object model:
NTAccount
object for the user account the application pool will run under:var account = new NTAccount("domain\user");
var processAccount = SPProcessAccount.LookupManagedAccount((SecurityIdentifier)account.Translate(typeof(SecurityIdentifier)));
var appPoolType = Type.GetType("Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPool, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"); var appPoolOptionsType = Type.GetType("Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPoolProvisioningOptions, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"); var noneOption = appPoolOptionsType.GetField("None").GetValue(appPoolOptionsType);
Create
and BeginProvision
methods of the application pool type to create the new application pool:var name = "Managed Metadata Service Application Pool"; var createMethod = appPoolType.GetMethod("Create", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(SPFarm), typeof(string), typeof(SPProcessAccount) }, null); var applicationPool = (SPIisWebServiceApplicationPool)createMethod.Invoke(null, new object[] { SPFarm.Local, name, processAccount }); applicationPool.Update(); var beginProvision = appPoolType.GetMethod("BeginProvision", BindingFlags.Instance | BindingFlags.NonPublic); beginProvision.Invoke(applicationPool, new object[] { noneOption });
var metadataAppType = Type.GetType("Microsoft.SharePoint.Taxonomy.MetadataWebServiceApplication, Microsoft.SharePoint.Taxonomy, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");
Create
method on the service application type to create the new service application:var createAppMethod = metadataAppType.GetMethod("Create", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(String), typeof(String), typeof(String), typeof(String), typeof(String), typeof(String), typeof(SPIisWebServiceApplicationPool), typeof(String), typeof(bool), typeof(bool), typeof(bool), typeof(int), typeof(int), typeof(bool) }, null); var mms = createAppMethod.Invoke(null, new object[] { "Managed Metadata Service", "ManagedMetadataDatabase", null, null, null, null, applicationPool, null, false, false, false, 0, 0, false });
Uri
property for the newly created service application:var mmsUri = (Uri)metadataAppType.GetProperty("Uri", BindingFlags.Instance | BindingFlags.Public).GetValue(mms);
var metadataProxyAppType = Type.GetType("Microsoft.SharePoint.Taxonomy.MetadataWebServiceApplicationProxy, Microsoft.SharePoint.Taxonomy, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");
CreateProxy
method to create the service application proxy:var createProxyMethod = metadataProxyAppType.GetMethod("CreateProxy", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(Uri), typeof(string), typeof(bool), typeof(bool), typeof(bool), typeof(Uri), typeof(bool), typeof(bool), typeof(bool) }, null); createProxyMethod.Invoke(null, new object[] { mmsUri, "Managed Metadata Service Proxy", false, false, false, null, false, true, false });
((SPServiceInstance)SPServer.Local.ServiceInstances.Where(p => p.TypeName.Equals("Managed Metadata Web Service", StringComparison.OrdinalIgnoreCase)).First()).Provision();
18.191.176.5