1 min read

ConfigurationErrorsException XConnectIndexer

During our process to configure SQL Always Encrypted for a client, one of the last steps to do is to rebuild the xdb indexes.

This means that the configuration of the IndexWorker in xc-search needs to be updated and you need to trigger the rebuild.

So update the AppSettings.config on the xc-search webapp in this path: wwwroot/App_Data/jobs/continuous/IndexWorker/App_Config/AppSettings.config

And add your ClientId and Secret:

<add key="AzureKeyVaultClientId" value="your-guid-value" />
<add key="AzureKeyVaultClientSecret" value="your-secret-value" />

We thought we configured everything correctly but received this error when running Sitecore.XConnectSearchIndexer.exe -requestrebuild

The error complains about CDATA or text element in the AppSettings.config

Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.TypeInitializationException: The type initializer for 'Sitecore.XConnect.Search.Indexer.InstanceSettings' threw an exception. ---> System.Configuration.ConfigurationErrorsException: The configuration section cannot contain a CDATA or text element. (C:\home\site\wwwroot\App_Data\jobs\continuous\IndexWorker\App_Config\AppSettings.config)

Well after ridiculous testing we found the culprit... don't have xml comments in the AppSettings.config.
If you have the same error, remove all comments from the file.

<!-- Don't have comments in the AppSettings file of the IndexWorker -->
<!--<add key="AzureKeyVaultClientId" value="old-value" />-->