New-SPWebApplicationAppDomain: The given key was not present in the dictionary.

Most likely you are visiting this page because you install and configure Apps for SharePoint 2013 and you want to support AAM, or Host-Header configured farms. http://technet.microsoft.com/en-us/library/dn144963(v=office.15).aspx

 

Your farm has March 2013 Public Update, you enabled app functionality for such setup:

$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$contentService.SupportMultipleAppDomains = $true
$contentService.Update()

but when you try to configure multiple app domains for each of your Web Applications / Zones (especially if it’s not the Default zone), the New-SPWebApplicationAppDomain Cmdlet is throwing the “The given key was not present in the dictionary” exception.

 

The given key was not present in the dictionary 01

New-SPWebApplicationAppDomain : The given key was not present in the dictionary.
At line:1 char:1
+ New-SPWebApplicationAppDomain -AppDomain XXXXXXX.XXXXX.XXXXXXXXXXXXXXXXXXXXXXXXX …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (Microsoft.Share…cationAppDomain:SPCmdletNewWebApplicationAppDomain) [New
-SPWebApplicationAppDomain], KeyNotFoundException
+ FullyQualifiedErrorId : Microsoft.SharePoint.Administration.SPAppCmdlets.SPCmdletNewWebApplicationAppDomain

 

This is happening because you have a SharePoint Web Application with multiple AAM (alternate access mappings) and you configured the AAMs without extending the Web Application. Most likely you needed additional AAMs and you configured the farm adding the URLs directly in the “Edit Public URLs” page (Central Administration -> Application Management -> Configure alternate access mappings -> Edit Public URLs).

 

Microsoft recommends to extend the Web Applications instead of editing directly the Zones. ”We recommend extending a Web application to a new IIS Web site for each zone you want to use. This provides a backing IIS Web site. We do not recommend reusing the same IIS Web site for multiple zones, unless you are specifically told to do so by Microsoft.” Even if the article refers for Microsoft Office SharePoint Server 2007, the rule is valid also for SharePoint 2010 and 2013. More details about Alternate Access Mappings and how they work here.

 

 

So, the Microsoft developers behind this Cmdlet followed this recommendation. To make New-SPWebApplicationAppDomain to work for your Alternate Access Mapping, you need:

 

1. To delete the problematic AAM zone (Central Administration -> Application Management -> Configure alternate access mappings)
The given key was not present in the dictionary 02

 

2. Extend you Web Application accordingly with your zone.
The given key was not present in the dictionary 03
The given key was not present in the dictionary 04
The given key was not present in the dictionary 05

The given key was not present in the dictionary 06

 

Please read my next article in case after extending the Web Application, New-SPWebApplicationAppDomain throws you “The IIS Web Site you have selected is in use by SharePoint. You must select another port or hostname.” exception.
New-SPWebApplicationAppDomain : The IIS Web Site you have selected is in use by SharePoint. You must select another
port or hostname.
At line:1 char:1
+ New-SPWebApplicationAppDomain -AppDomain XXXXXXX.XXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXX …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (Microsoft.Share…cationAppDomain:SPCmdletNewWebApplicationAppDomain) [New
-SPWebApplicationAppDomain], ArgumentException
+ FullyQualifiedErrorId : Microsoft.SharePoint.Administration.SPAppCmdlets.SPCmdletNewWebApplicationAppDomain

 

Leave a Reply