Switch Sitecore 9 From Solr to Azure Search -- Step-By-Step Instructions

In a previous article I provided instructions on how to switch your Sitecore website from Azure Search to Solr. In this post I'll come at it from the other direction, switching from Solr to Azure Search.

Why would you want to do this? In my case, I'm developing a new Sitecore website which will have a production environment in an Azure PaaS, but I have a local development environment which I installed using SIF (which installs Solr as my search engine). While I could theoretically have Solr locally and use Azure Search in production (using gulp and config transforms), I strongly prefer to develop against the same kind of infrastructure that I will ultimately have in Production. So the solution for me was to change my local dev environment to use Azure Search.

The first step will be to set up your Azure Search instance. In my case I have a Microsft MSDN subscription with a $150/month credit which I will use to pay for my development search index in Azure. My Azure Search service is running around $28/month, but your costs will vary. 

  1. Log in to Azure Portal: https://portal.azure.com
  2. Click “All Services”, and search for “search services”. Click the Search Services app.
  3. Click the plus sign to add a new search service.
  4. Add the following information to the form:
    Url: create a unique url for the search service, for example “<your project>-<your initials>.search.windows.net”
    Subscription: Select your subscription
    Resource Group: Enter a name for your new resource group
    Location: Select a location physically close to you
    Pricing Tier: Select the least expensive one possible. In my case I will select "Basic"



  5. Click Create to create your new search service.
  6. Click in to your new service and select the Overview tab, and make note of the Service URL.
  7. Click the Keys tab and make note of the PRIMARY ADMIN KEY.

Now we need to configure Sitecore and xConnect to use the new search service.

  1. Open the Sitecore connection string file for your published website, which lives in the following location: <web root>\App_Config\ConnectionStrings.config.
  2. Comment out the search connection string, and add in your new cloud.search connection string per the following example:

    <add name="cloud.search" connectionString="serviceUrl=<your url>;apiVersion=2017-11-11;apiKey=<your primary admin key>" />

  3. Navigate to <web root>\<xconnect instance>\App_Data\Config\Sitecore\CollectionSearch and enable the sc.Xdb.Collection.IndexReader.AzureSearch.xml.disabled file by removing the “.disabled” extension. Then disable the sc.Xdb.Collection.IndexReader.SOLR.xml and sc.Xdb.Collection.WebClient.SOLR.xml files by adding the “.disabled” extension.
  4. Navigate to <web root>\<xconnect instance>\App_Data\Config\Sitecore\SearchIndexer and enable the sc.Xdb.Collection.IndexWriter.AzureSearch.xml.disabled file by removing the “.disabled” extension. Then disable the sc.Xdb.Collection.IndexWriter.SOLR.xml file by adding the “.disabled” extension.
  5. Navigate to <web root>\<xconnect instance>\App_Data\jobs\continuous\IndexWorker\App_data\config\sitecore\CollectionSearch and enable the sc.Xdb.Collection.IndexReader.AzureSearch.xml.disabled file by removing the “.disabled” extension. Then disable the sc.Xdb.Collection.IndexReader.SOLR.xml and sc.Xdb.Collection.WebClient.SOLR.xml files by adding the “.disabled” extension.
  6. Navigate to <web root>/<xconnect instance>\App_Data\jobs\continuous\IndexWorker\App_data\config\sitecore\SearchIndexer and enable the sc.Xdb.Collection.IndexWriter.AzureSearch.xml.disabled file by removing the “.disabled” extension. Then disable the sc.Xdb.Collection.IndexWriter.SOLR.xml file by adding the “.disabled” extension.
  7. Navigate to <web root>\<xconnect instance>\App_Config\ConnectionStrings.config and comment out the solrCore connection string. Then add a new connection string in the following format:

    <add name="search" connectionString="serviceUrl=<your url>;apiVersion=2017-11-11;apiKey=<your primary admin key>" />

  8. Navigate to <web root>\<xconnect instance>\App_Data\jobs\continuous\IndexWorker\App_Config\ConnectionStrings.config and comment out the solrCore connection string. Then add a new connection string in the following format:

    <add name="search" connectionString="serviceUrl=<your url>;apiVersion=2017-11-11;apiKey=<your primary admin key>;indexName=xdb" />

  9. To test if all your changes were successful, open a command prompt and change directory to <web root>\<xconnect instance>\App_Data\jobs\continuous\IndexWorker. Type "xConnectSearchIndexer -rr" and hit enter to start a rebuild. When completed, you should see the following:

NOTE: If the above step does not work, ensure that the following 3 Windows services are running. (If one of them won't start, see the event log to determine the cause, and correct it). 

  • Sitecore Marketing Automation Engine
  • Sitecore Processing Engine
  • Sitecore xConnect Search Indexer

    11. Now you can rebuild the rest of your search indexes in Sitecore. When finished, you should have the 9 required indexes. (I have 11 because of a couple custom ones):


    12. Lastly, stop your Solr service and uninstall it.

That's it, you are now connected to Azure Search! I tested this with Sitecore 9.1, but it will work with version 9.0 as well.

If you have any corrections or ideas on better ways to accomplish this, please let me know.

~David

Add comment

Loading