Configure Coveo for Sitecore with the legacy Sitecore Azure module

This article describes how an administrator can configure Coveo for Sitecore to work with the Sitecore Azure module.

Important

Even if Coveo for Sitecore can run in such a setup, be aware that it’s not an officially supported use of the product.

Configuring the Deployment Manager

The Deployment Manager (DM) is responsible for maintaining the delivery farm within Azure. Follow these steps to complete the prerequisites for the farm:

  1. Read About the Coveo for Sitecore infrastructure with the legacy Sitecore Azure module.

  2. Install and configure the Sitecore instance that you will use as the Deployment Manager (DM).

  3. Install Coveo for Sitecore on the Deployment Manager.

Note

Unlike the Sitecore on-premises environments with content manager (CM) and content delivery (CD) instances, the files used by Coveo for Sitecore don’t need to be copied manually to every CM and CD instance. When deploying to Windows Azure, the Sitecore Azure module takes care of copying the files to the other instances.

Performing the initial indexing

Once Coveo for Sitecore has been installed and configured on the Deployment Manager (DM), it’s time to build the indexes for the first time.

  1. In the Coveo.SearchProvider.Custom.config file, set the farm name (see Assign a farm name to resources).

  2. If not done already, publish the whole site to the web database.

  3. Rebuild the indexes (see Coveo for Sitecore indexing guide).

At this point, every Sitecore item should have been indexed by the Coveo Platform. You can validate that the index contains the expected documents using the Coveo Content Browser.

Preparing configuration for CDs

Important

The following steps requires that you edit and add nodes to the Coveo Search Provider configuration files. Always make such changes in the Coveo.SearchProvider.Custom.config file. Don’t modify the Coveo.SearchProvider.config as this file is overwritten during the upgrade process and all changes will be lost.

Now that the DM instance is working, the configuration files can be modified to allow CDs to be deployed (see Scaling guide).

Step 1: Creating the CD farm

  1. Open the Sitecore Azure management panel.

  2. Select Development [Staging] or Development [Production] from the Environment Type dropdown menu. A dialog window should present a world map showing the available datacenters.

  3. Click a datacenter to see farms or to create new ones.

    Tip

    Here is the datacenter color code:

    Gray: No farm in the datacenter.

    Blue: A farm exists, but the site isn’t deployed yet.

    Yellow: Site is being deployed.

    Green: Site has been deployed successfully.

    Red: An error occurred or the cloud service is suspended.

  4. Deploy a Delivery farm. You can expect the deployment to last anywhere between 10 and 15 minutes for a cloud-based deployment manager or 30 to 40 minutes for an on-premises DM.

Step 2: Creating a new index for the CDs database

Since the deployment manager can be installed on-premises, the CDs won’t share the same databases as the DM. When deploying the CDs, the core and web databases are copied in the cloud and become Azure databases in the process. Then, a publishing target is added to the DM, allowing content authors to publish new content directly to the delivery farm.

In the previous step, you added a new database for the CDs. However, there are no indexes configured to crawl its content. A new search index definition must be added to the DM configuration file.

  1. Find the CDs database name:

    1. Open the App_config/ConnectionStrings.config file.

    2. Find the database entry that matches the delivery farm.

    3. Copy the database name from the name attribute.

  2. Edit the Coveo.SearchProvider.Custom.config file.

    1. Duplicate the Coveo_web_index index definition.

    2. Update the index name. For example, you can set it to Coveo_web_cd_index.

    3. Update the database name in both the crawler and strategy elements.

    4. The new index definition should look like this.

       <index id="Coveo_web_cd_index" type="Coveo.SearchProvider.ProviderIndex, Coveo.SearchProvider">
         <param desc="p_Name">$(id)</param>
         <configuration ref="coveo/defaultIndexConfiguration" />
         <locations hint="list:AddCrawler">
           <crawler type="Coveo.SearchProvider.CoveoItemCrawler, Coveo.SearchProviderBase">
             <database>the_Azure_database_name</database>
             <root>/sitecore/content</root>
             <stopOnError>true</stopOnError>
           </crawler>
           <crawler type="Coveo.SearchProvider.CoveoItemCrawler, Coveo.SearchProviderBase">
             <database>the_Azure_database_name</database>
             <root>/sitecore/media library/files</root>
             <stopOnError>true</stopOnError>
           </crawler>
         </locations>
         <strategies hint="list:AddStrategy">
           <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/onPublishEndAsync"/>
         </strategies>
         <propertyStore ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)"/>
       </index>
  3. Rebuild the new index.

Step 3: Freezing the source name for the CD

The last thing left to do is to ensure that the CD instances will target the search index that was added in the previous step. This is an important step, as the search index content must match the Sitecore instance content. If a CD instance uses a content database and a search index tied to another database, then it might return wrong results or even break the whole site.

On the deployment server, there are the following databases and indexes:

Database Search index

master

Coveo_master_index

web

Coveo_web_index

the_Azure_database_name

Coveo_web_cd_index

However, the CD instances are slightly different from the DM. Not only do they not have the master database, but their web database targets an Azure database instead of the original web database.

What you want for the CD is to have a Coveo_web_index that uses the same Coveo source as the DM. In other words, the source name must be explicitly set on the CM to match the source created for the Coveo_web_cd_index on the DM. To do so, you can use a Sitecore include file to alter the SourceName setting. It’s possible to add include files that are applied only when deploying Azure farms. Include files should work as usual.

Important

When deploying the instance, the Sitecore Azure module simplifies the configuration files by merging all the include files together as usual. Then, it breaks the whole configuration element into smaller include files again. This means that the settings that were set in a specific file on the DM are in another file on the CDs. For example, the settings defined in the Coveo.SearchProvider.config and Coveo.SearchProvider.Custom.config files are moved to contentSearch.config in the CD package.

There’s also a special folder that must be used to apply specific settings when deploying a farm to Azure. The folder location is <SITECORE_INSTANCE_ROOT>\Website\AzureOverrideFiles. As the folder name suggests, files put into this folder override the website files.

Here is a sample file showing you how to set the source name of the Coveo_web_index for the CDs.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <contentSearch>
      <configuration type="Coveo.SearchProvider.Configuration.CoveoSearchConfiguration, Coveo.SearchProvider">
        <indexes hint="list:AddIndex">
          <index id="Coveo_web_index" type="Coveo.SearchProvider.ProviderIndex, Coveo.SearchProvider">
            <strategies hint="list:AddStrategy">
              <patch:delete />
            </strategies>
            <sourceName>Source name for the_Azure_database_name</sourceName>
          </index>
          <index id="Coveo_master_index" type="Coveo.SearchProvider.ProviderIndex, Coveo.SearchProvider">
            <patch:delete />
          </index>
          <index id="Coveo_web_cd_index" type="Coveo.SearchProvider.ProviderIndex, Coveo.SearchProvider">
            <patch:delete />
          </index>
        </indexes>
      </configuration>
    </contentSearch>
  </sitecore>
</configuration>
Note

When deploying a delivery farm, the Sitecore Azure module generates an Azure package in the sitecore instance\Data\AzurePackages folder. You might want to verify the package content to ensure that the effective CD configuration matches the expected configuration.

At this point, the delivery farm can be safely deployed to target the right index source. Publishing to the CDs database will also rebuild the appropriate search index, keeping the search results synchronized with the CDs content.