3

I am getting an exception/error while I am creating contact though xConnect Code,

below is my code:

using (var client = CreateClient())
            {
                try
                {
                    var source = "Subcribe.Form";
                    var id = CurrentTracker.Contact.ContactId.ToString("N");
                    CurrentTracker.Session.IdentifyAs(source, id);
                    var trackerIdentifier = new IdentifiedContactReference(source, id);
                    var expandOptions = new ContactExpandOptions(
                        CollectionModel.FacetKeys.PersonalInformation,
                        CollectionModel.FacetKeys.EmailAddressList);
                    Contact contact = client.Get(trackerIdentifier, expandOptions);
                    SetPersonalInformation(GetValue(firstNameField), GetValue(lastNameField), contact, client);
                    SetEmail(GetValue(emailField), contact, client);
                    client.Submit();
                    return true;
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex.Message, ex);
                    return false;
                }
            }

I am getting error on client.Submit() method , as below:

Exception: Sitecore.XConnect.XdbCollectionUnavailableException
Message: {
  "Message": "Operation failed: One or more dependencies failed",
  "ExceptionMessage": "One or more dependencies failed",
  "ExceptionType": "Sitecore.XConnect.Operations.DependencyFailedException",
  "StackTrace": null,
  "InnerException": {
    "Message": "An error has occurred.",
    "ExceptionMessage": "Scaled database was not configured properly: the range shard map has to be configured.",
    "ExceptionType": "Sitecore.Xdb.Collection.Failures.ScaledDatabaseConfigurationException",
    "StackTrace": "   at Sitecore.Xdb.Collection.Data.SqlServer.Configuration.ElasticScaleConnectionManager.GetRangeShardMap(String rangeShardMapName)\r\n   at Sitecore.Xdb.Collection.Data.SqlServer.Configuration.ElasticScaleConnectionManager.<>c__DisplayClass37_0.<GetRangeMappings>b__0()\r\n   at System.Lazy`1.CreateValue()\r\n   at System.Lazy`1.LazyInitValue()\r\n   at Sitecore.Xdb.Collection.Data.SqlServer.Configuration.MemoryCacheManager.AddOrGetExistingFromCache[T](String key, Func`1 valueFactory)\r\n   at Sitecore.Xdb.Collection.Data.SqlServer.Configuration.ElasticScaleConnectionManager.MapKeysToShards[TPartitionKey,TEntityKey](String rangeShardMapName, IReadOnlyCollection`1 keys)\r\n   at Sitecore.Xdb.Collection.Data.SqlServer.Managers.SqlDataRecordsManager`2.<GetAsync>d__49.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Sitecore.Xdb.Collection.Data.SqlServer.SqlDataProvider.<GetDeviceProfilesById>d__13.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Linq.AsyncEnumerable.<>c__DisplayClass440_0`1.<<ToAsyncEnumerable>b__1>d.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Linq.AsyncEnumerable.AnonymousAsyncIterator`1.<MoveNextCore>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Linq.AsyncEnumerable.AsyncIterator`1.<MoveNext>d__10.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Linq.AsyncEnumerable.SelectManyAsyncIterator`2.<MoveNextCore>d__10.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Linq.AsyncEnumerable.AsyncIterator`1.<MoveNext>d__10.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Linq.AsyncEnumerable.<ForEachAsync_>d__174`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Sitecore.XConnect.Service.RepositoryGetInvoker.<UpdateGetOperations>d__7`2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Sitecore.XConnect.Service.RepositoryGetInvoker.<>c__DisplayClass4_1.<<Execute>b__19>d.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Sitecore.XConnect.Service.RepositoryGetInvoker.<FailOperationsOnException>d__5.MoveNext()"
  }
}
Source: Sitecore.Xdb.Common.Web
   at Sitecore.Xdb.Common.Web.Synchronous.SynchronousExtensions.SuspendContextLock[TResult](Func`1 taskFactory)
   at Sitecore.XConnect.Client.XConnectSynchronousExtensions.SuspendContextLock[TResult](Func`1 taskFactory)
   at Sitecore.XConnect.Client.XConnectSynchronousExtensions.Get[TEntity](IXdbContext context, IEntityReference`1 reference, ExpandOptions expandOptions, TimeSpan timeout)
   at Sitecore.Analytics.XConnect.DataAccess.XConnectDataAdapterProvider.<>c__DisplayClass26_0.<GetDevice>b__1(IXdbContext xdbContext)
   at Sitecore.Analytics.XConnect.DataAccess.XConnectDataAdapterProvider.ExecuteWithExceptionHandling[T](Func`2 func)

I checked the xConnect collection URL and its up and running as below:

enter image description here

Below is my connection string for xconnect collection:

<add name="xconnect.collection" connectionString="https://Sitecore9.Xconnect" />
  • Could you open ShardMapManager database in SQL Server and query ShardsGlobal and ShardMappingsGlobal tables? – grg Feb 11 '18 at 17:03
  • Can u check if you have done this on your web.config <add key="AllowInvalidClientCertificates" value="true" />? – Jovit Mayo Mar 1 '18 at 8:00
  • did you find a solution for this? having the same problem – Żubrówka Jan 4 '19 at 11:05
  • I also have the same problem. – Emanuele Ciriachi May 20 '19 at 11:40
  • @Żubrówka: Have you been able to fix it? I am getting the same error. – NutsAndBolts Nov 18 '19 at 13:14
0

Have you already tried to manually check the shards assignemnt in the [projectname].Collection.ShardMapManager?

If not, you can try this sql script to see if the server name and the database name are correct

/****** Script for SelectTopNRows command from SSMS  ******/
SELECT TOP (1000) [ShardId]
      ,[Readable]
      ,[Version]
      ,[ShardMapId]
      ,[OperationId]
      ,[Protocol]
      ,[ServerName]
      ,[Port]
      ,[DatabaseName]
      ,[Status]
  FROM [{projectname}.Collection.ShardMapManager].[__ShardManagement].[ShardsGlobal]

And based on the information you see there you can create a update query to modify the servername accordingly.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.