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.
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:
- Indexer synchronizes Azure Search and the Database.
- The Synchronization updates the Indexes.
- REST API that enables developers to query the indexes.
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)
- Create a new SQL Database resource.
- Fill the Information for the DB, (Remember the password for SQL Server)
- Important: Select Source “Sample (AdventureWorksLT)“, see Figure 2.
- Click “Create”
Done! Let’s continue with Azure Search.
Creating the Azure Search service
- Create a new Azure Search resource.
- 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:
- Select the Azure Search service, in my case demo-azure-search.
- In Overview click Import data ()
- Do the steps as shown in Figure 4.
- After Selecting the Database, provide the SQL Server username and password. Select the SalesLT.Product table, Click OK.
- Next Stop creating an Index for products follow figure 5.
- 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!