Could not create instance of type: Sitecore.ContentSearch.Azure.CloudSearchProviderIndex. No matching constructor was found

A. Scenario

Open Indexing Manager in Sitecore dashboard, the error below appears


B. Triaging

My Sitecore instance was deployed on Azure by another party. It was configured to used SOLR cloud as search engine. I want to switch to Azure Cognitive Search. 

It was supposed to be a simple switch by updating the app setting value in the web.config from 

<add key="search:define" value="Solr"/> to <add key="search:define" value="Azure"/>

But it was not.

C. Debugging

Step 1: Understand basic knowledge

For each of the indexes found in the Indexing Manager, it is created from a config file. For example, the sitecore_testing_index is configured with either Sitecore.ContentTesting.Solr.IndexConfiguration.config or Sitecore.ContentTesting.Azure.IndexConfiguration.config

Depending on whether we use the search:define value as Solr/Azure, one file will be activated and the other one will be deactivated accordingly.

Looking at the sitecore_testing_index section in the file Sitecore.ContentTesting.Azure.IndexConfiguration.config


This mean if Azure Cognitive Search is enabled, Sitecore will need to initialize the class Sitecore.ContentSearch.Azure.CloudSearchProviderIndex with the 4 params: name, connectionStringName, totalParallelServices, propertyStore

I learned it the hard way by decompiling the Sitecore.ContentSearch.Azure.dll

Switching to the file Sitecore.ContentTesting.Solr.IndexConfiguration.config, the  sitecore_testing_index section look like this:



This mean if SOLR is enabled, Sitecore will need to initialize the class Sitecore.ContentSearch.SolrProvider.SolrSearchIndex with the 3 params: name, core,  propertyStore

Step 2: Fix bug

From the above investigation, it is understood that each search index class accepts a different set of parameters during initialization.

Above error screenshot tell me that my class Sitecore.ContentSearch.Azure.CloudSearchProviderIndex is now are getting some odd parameter other than the 4 above mentioned

With the help of showconfig.aspx page, I managed to drill down to the culprit sitecore_testing_index section (after checking through many other "normal" indexes) and it shows an additional core param. It was inserted by some patch configuration file from the party in charge of installation. They obviously add it to work with SOLR but forget about Azure Cognitive Search. 

Disable that patch file and everything works as usual.

D. Conclusion

It is not likely you will get this error from Sitecore OOTB installation. However be careful when adding additional configuration. You need to consider the differences between SolrSearchIndex & CloudSearchProviderIndex as I mentioned.

Happy Sitecoring!


Comments

Popular posts from this blog

Sitecore XP 9.2 - Scaling with Dedicated CD - Quick Installation [part 2]

Troubleshooting Sitecore XP 9.2 - Experience Analytics error - Exception System.ArgumentNullException: typeKey should not be null.

CI/CD with TeamCity + Sitecore 9.2 + Unicorn