After configuring Sitecore 9 and xConnect, you may come across the following error in the xConnect logs when you’re trying to use the API:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2017-10-29 21:23:30.052 +00:00 [Error] ["XdbContextLoggingPlugin"] XdbContext Batch Execution Exception
Sitecore.XConnect.Operations.DependencyFailedException: One or more dependencies failed --->
Sitecore.Xdb.Collection.Failures.DataProviderException: Postcondition 'The shard map manager has to be configured.' failed. --->
Sitecore.Framework.Conditions.PostconditionException: Postcondition 'The shard map manager has to be configured.' failed.
at Sitecore.Framework.Conditions.EnsuresValidator`1.ThrowExceptionCore(String condition, String additionalMessage, ConstraintViolationType type)
at Sitecore.Framework.Conditions.Throw.ValueShouldBeTrue[T](ConditionValidator`1 validator, String conditionDescription)
at Sitecore.Xdb.Collection.Data.SqlServer.Configuration.ElasticScaleConnectionManager.InitializeShardMapManager()
at Sitecore.Xdb.Collection.Data.SqlServer.Configuration.ElasticScaleConnectionManager.get_ShardMapManager()
at Sitecore.Xdb.Collection.Data.SqlServer.Configuration.ElasticScaleConnectionManager.GetRangeShardMap(String rangeShardMapName)
at Sitecore.Xdb.Collection.Data.SqlServer.Configuration.ElasticScaleConnectionManager.<>c__DisplayClass37_0.<GetRangeMappings>b__0()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at Sitecore.Xdb.Collection.Data.SqlServer.Configuration.MemoryCacheManager.AddOrGetExistingFromCache[T](String key, Func`1 valueFactory)
at Sitecore.Xdb.Collection.Data.SqlServer.Configuration.ElasticScaleConnectionManager.MapRecordsToShards[T](String rangeShardMapName, IReadOnlyCollection`1 records, Func`2 getShardKey)
at Sitecore.Xdb.Collection.Data.SqlServer.Managers.SqlContactRecordsManager.<GetContactIdentifiersFromIndexAsync>d__5.MoveNext()

Despite the slightly cryptic error message, the cause of this is actually fairly straightforward. If you see this error, this is an indicator that xConnect cannot connect to the Xdb.Collection.ShardMapManager database, which is attempted in the InitializeShardMapManager method, where this exception is being thrown.

Though the underlying SQL error doesn’t appear to be logged, to diagnose the problem, you should confirm that the collection connection string in the configuration is correct:

1
<add name="collection" connectionString="user id=collectionuser;password=***PASSWORD***;data source=localhost;Initial Catalog=sc90_Xdb.Collection.ShardMapManager" />

In my instance, the Sitecore 9 install hadn’t correctly created the collectionuser login in SQL Server, so I just had to create this login and add it to the sc90_Xdb.Collection.ShardMapManager database. I confirmed that the connection string worked and provided access to the ShardMapManager database, and after that point, the error disappeared and I was able to push data into xConnect.

This error occurs if the post-installation manual steps are not completed. For Sitecore 9.0, these are found in Chapter 6 of the installation guide.