Get started with Azure Search in 10 minutes

Problem

Azure Search sounds nice and everything, but I need an Azure Search quick setup so that I can play around with it.

For those new to Azure Search, read up in the official documentation, there is also a great video.

Solution

Azure Search enables indexing of a Database, be it SQL or NoSQL, and then enables myriad features like Search suggestions, scoring, language analyzers through a REST API.

To summerise, the Azure Search components are shown in the image:

  1. Indexer synchronizes Azure Search and the Database.
  2. The Synchronization updates the Indexes.
  3. REST API that enables developers to query the indexes.
Fig. 1. Main Components of Azure Search

 

Sounds simple, let’s get started!

Setting everything up

To be able to create Indexes we need a Database with data, for that reason (and to stay under 10 minutes) we will use the default AdventureWorks DB.

Creating the Azure SQL Database (AdventureWorksLT)

In the Azure Portal:

  1. Create a new SQL Database resource.
  2. Fill the Information for the DB, (Remember the password for SQL Server)
  3. Important: Select Source “Sample (AdventureWorksLT)“, see Figure 2.
  4. Click “Create”

Done! Let’s continue with Azure Search.

Creating the Azure Search service

In the Azure Portal:

  1. Create a new Azure Search resource.
  2. Fill with default information.

The URL is the endpoint where you will make requests to the Azure Search API.

 

Adding one plus one

In the Azure Portal:

  1. Select the Azure Search service, in my case demo-azure-search.
  2. In Overview click Import data ()
  3. Do the steps as shown in Figure 4.

    Fig. 4. Settings for importing data from Azure SQL
  4. After Selecting the Database, provide the SQL Server username and password. Select the SalesLT.Product table, Click OK.
  5. Next Stop creating an Index for products follow figure 5.

    Fig. 5. Creating an Index
  6. Set up the Synchronization Schedule (i.e. How often the index should be updated from the new data in the Database, this is related to the Enterprise)

All steps completed. Wait a couple of minutes and refresh the page, in the overview of the Azure Search service you will find that Document Count has gone up to 295 for the index that we created.

Querying Azure Search

Select the index product-index and click Search Explorer.

Search Explorer blade opens. Type search=bike in the Query string field. A list of JSON objects will be returned presenting all the retrievable data we checked in Figure 5.

The query capabilities are quite complex, read up the official documentation how to query Azure Search indexes.

In this article, I present how to wrap the Azure Search SDK using a fluent API.

We are finished, and that was about 9 minutes and 58 seconds 😉

If you enjoyed the article, please share and comment below!