Gauri Mahajan
Data Items

Creating an Azure Search service instance for Azure Cosmos DB

November 4, 2021 by

In this article, we will learn how to create an instance of Azure Search service and attach it to an instance of Azure Cosmos DB.


Data can be hosted in a variety of data repositories depending on the nature of data. For example, on the Azure platform, key-value type data can be hosted on Cosmos DB, relational data can be hosted on Azure SQL Database or Azure Database for PostgreSQL, file-based data can be hosted on Azure Data Lake Storage etc. One common requirement across different types of data repositories and data types is data consumption. Searching data is one of the most common user-friendly ways of consuming and discovering data from data repositories. Azure Search service is one of the core services that serve this exact purpose. In this article, we will learn how to create an instance of Azure Search service and attach it to an instance of Azure Cosmos DB.

Creating Azure Cosmos DB Instance

As we are going to attach an instance of Azure Search to Cosmos DB, we firstly need an instance of Cosmos DB. We would need an Azure account with administrative privileges to work with Azure Cosmos DB. It is assumed that this account and setup are already in place. Navigate to the Azure portal and open the home page of Cosmos DB. Click on the Create button to invoke the new instance creation wizard. In the first step, we would be presented with the options as shown below. One of the most common models of Cosmos DB is the Core SQL API. To select it, click on the Create button and move to the next step.


In the next step, we need to provide basic details like subscription, resource group, name of the new account being created, the region in which the new account would be created. There are two options for capacity mode – Provisioned throughput or Serverless. We would use the serverless mode for this exercise. We can use the default options for the rest of the details. To quickly create an instance of Azure Cosmos DB, we can just click on the Create + Review button which will navigate us to the final step before instance creation.

Basic details

In this step, we can just review the configuration that we did in the first step, and the rest of the defaults. After reviewing, we can click on Create button which will start the creation of a new instance.

Review Details

Once the new instance is created, we need to create at least one database with one container in it. Once the container is created, we need to add items to this container. We can even use the sample database and container that gets created using the sample scripts available with Cosmos DB. Once the same gets created, it would look similar to the one shown below.

Data Items

Creating and Associating an Azure Search Instance

Now that we have the Cosmos DB instance and the data set up in this instance, we can create a new Azure Search instance and associate it with the Cosmos DB instance. There are two parts to making a search operational with any data source. One is the creation of a search instance and another part is configuring the search depending upon the type of data source. Our focus here is to just create an instance of Azure Search that can be used with Cosmos DB. We can configure the instance when the data volume reaches a reasonable level and data consumption need using a search-based mechanism is required.

Click on the Add Azure Cognitive Search menu item and it will open a page as shown below. We do not have an existing Azure Search instance, so we need a new one. We can create the search instance from the Azure Search home page, but that would not be associated with Azure Cosmos DB, and we would have to perform an extra step to associate it. Instead, by creating a search instance from Cosmos DB itself, it would serve a dual purpose of creating a new instance as well as attaching it.

Cognitive Search

Click on the message shown above to invoke the new search instance creation wizard. It would open a new wizard in turn as shown below. We need to select basic details like subscription, resource group, name of the search service instance, location in which the instance would be created, as well as the pricing tier. For this exercise, we will continue with the defaults.

New Search Service

The next step is related to scaling the availability of the instance by creating replicas. The cost of replicas is as shown below. In this step as well, we will continue with the defaults as we do not require high availability for this exercise.

Scaling options

For networking, we will continue with the default mode of network endpoint connectivity i.e., Public. In the next step, we can optionally configure any tags we intend to add to this instance, and then navigate to the last step where we can review the configuration details.

Networking details

Once we are on the final screen, we should get a validation success message as shown below. After reviewing the details, we are ready to create a new instance. Click on the Create button to create the new instance.

Review Search Instance Details

This will initiate the creation of the new Azure Search instance. Once the instance is created, we would be able to find that the search service is not listed under the Azure Cosmos DB account. This search instance is not yet tied up with the database but is discoverable and ready for use with Cosmos DB.

Usable search instance

In this way, we can create an Azure Search service instance that can be used with Azure Cosmos DB.


In this article, we created an instance of Azure Cosmos DB and explored different configuration options to create the same. After creating the database instance as well as data, we learned how to create a new Azure search instance that can be used with this database.

Gauri Mahajan
Azure, Azure Cosmos DB

About Gauri Mahajan

Gauri is a SQL Server Professional and has 6+ years experience of working with global multinational consulting and technology organizations. She is very passionate about working on SQL Server topics like Azure SQL Database, SQL Server Reporting Services, R, Python, Power BI, Database engine, etc. She has years of experience in technical documentation and is fond of technology authoring. She has a deep experience in designing data and analytics solutions and ensuring its stability, reliability, and performance. She is also certified in SQL Server and have passed certifications like 70-463: Implementing Data Warehouses with Microsoft SQL Server. View all posts by Gauri Mahajan