Sitecore Azure Search: How to name indexes for distinct environments

Hi there ! In this post I will give you a quick overview of Sitecore Azure Search and give you a solution for one of problems that i faced with azure Search , how we can share azure search service between distinct environments.

What is Azure Search ?

Azure Search is a search-as-a-service cloud solution that gives developers APIs and tools for adding a rich search experience over private, heterogenous content in web, mobile, and enterprise applications. Query execution is over a user-defined index.

What is Sitecore Azure Search provider ?

The Sitecore Azure Search provider integrates the Sitecore Search engine with the Microsoft Azure Search service. The Microsoft Azure Search service is a part of the Microsoft Azure computing platform, you can read more about the Microsoft Azure Search service on their website.

Background :

Basically, in Sitecore project, we have different environments (develop, preprod,Prod,etc..). Imagine if the indexes have the same name, they will be shared by all environments, that will be a big problem !

Solution ?

Add prefix per environment to all indexes Sitecore names to differentiate which index for which environment. Eg: local-sitecore-master-index for  local environment, preprod-sitecore-master-index for preprod environment.

How to implement that ?

  • Add index name prefix setting to Appsettings.config

  • Retreive index prefixe value in Appsettings.cs

  • Create a custom cloud search provider Index

  • Change the native cloud search provider by the Custom Cloud Search Provider Index wich i just created.

The Sitecore.ContentSearch.Azure.Index.Master.config file should look like below :

Finally, result on azure search service below  🙂

2 thoughts on “Sitecore Azure Search: How to name indexes for distinct environments”

Leave a comment