Day 4 — Azure Open AI: Setup Azure AI Search Solution
Tags: ai, webdev, programming, beginners
Published: 2024-03-29 11:06:33

A day dedicated to Azure Open AI, focusing on harnessing Azure AI Search for document indexing and enrichment

The Microsoft team has recently launched an Open AI challenge, in which a developer can learn how to build Azure AI solutions and apps.

## Introduction

The article demonstrates how to use Azure AI Search to develop a solution where documents undergo indexing and enrichment through AI skills, enhancing their searchability.

### Why Azure AI search?

Azure AI Search leverages advanced AI and machine learning to enrich indexing and search capabilities. It can automatically understand the content within documents, images, and other media types, extracting valuable information, identifying patterns, and even understanding sentiments. These capabilities allow for more nuanced and intelligent search results.

### Prerequisite

* Experience working with Azure and Azure portals.

* An understanding of generative AI.

* Experience in one high-level programming language like C# or Python

## Getting Started

Before starting the actual implementation, 3 different Azure resources need to be set up before moving forward.

* Setup Azure AI Search

* Setup Azure AI Service

* Setup Azure Storage Account

> Your Azure AI Search and Azure AI Services resources must be in the same location!

Once the above prerequisites are completed, you need to perform the following steps in the Azure Portal

* Upload documents to Azure Blob Storage

* Index the documents

* Testing

## Setup Azure AI Search

### Step 1: Navigate to the [Azure Portal](https://portal.azure.com/)

Search for **Azure AI Search** and fill out the following details

![](https://cdn-images-1.medium.com/max/2000/1*IV0EPZlu0NPAqpasUNio9Q.png)

### Step 2: Scaling Configuration

Since I am using the free pricing tier, I cannot add scaling capabilities or create replicas as shown below

![](https://cdn-images-1.medium.com/max/2000/1*lg6jtkaCW16Dpunk1QhZpA.png)

### Step 3: Create tags

For this exercise tag names are not required. But in a production environment, it should be added as it’s a best practice.

![](https://cdn-images-1.medium.com/max/2000/1*f9ptc2N1315dFbUBHVCwEw.png)

### Step 4: Review & Create

Post validation checks by Azure Cloud, and proceed with creating the resource. Make sure you review the details entered in the previous steps.

![](https://cdn-images-1.medium.com/max/2000/1*GptGlWgg-2Na-HYYqztALg.png)

## Setup Azure AI Service

### Step 1: Create Azure AI Service

Now let's create another service, that searches for **Azure AI Service **and fills out the following details

![](https://cdn-images-1.medium.com/max/2000/1*vXRYT4dr30IBe5NTWoubxg.png)

Now, continue with the remaining steps as default options are selected, create the service and finally wait for the service to be deployed.

### Step 2: Network Defaults

![](https://cdn-images-1.medium.com/max/2000/1*lCugwdg-AurWVH_G-_l-mw.png)

### Step 3:Identity Defaults

![](https://cdn-images-1.medium.com/max/2000/1*OcK_dF9EBXp0BlYLulFgkg.png)

### Step 4: Review & Create

Post validation checks by Azure Cloud, and proceed with creating the resource. Make sure you review the details entered in the previous steps.

![](https://cdn-images-1.medium.com/max/2000/1*l2GoBexaw7wL_1TwHE2NSw.png)

## Setup Azure Storage Account

### Step 1: Create an Azure Storage Account

Now let’s create another service, that searches for **Azure Storage Account **and fills out the following details

![](https://cdn-images-1.medium.com/max/2000/1*Edu8Kym7ysFG-34B9SOSOg.png)

### Step 2: Allow anonymous access

In the Advanced tab, check the box next to *Allow enabling anonymous access on individual containers*

![](https://cdn-images-1.medium.com/max/2000/1*9aIOej_witckQIkZvIZcQA.png)

### Step 3: Review & Create

Now, continue with the remaining steps as default options are selected, create the service and finally wait for the service to be deployed.

![](https://cdn-images-1.medium.com/max/2000/1*zfzE60Te21AkCqa6LhEH3g.png)

## Upload documents to Azure Blob Storage

With the necessary resources in place, proceed to upload documents to your Azure Storage account.

Follow the article provided by Microsoft.

[Quickstart: Upload, download, and list blobs - Azure portal - Azure Storage](https://learn.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-portal)

## Index the Documents

Open Azure AI Service and under the Overview tab, select “Import Data” as highlighted below

![](https://cdn-images-1.medium.com/max/2702/1*kXc284V_v0S6SvrOIEUl5A.png)

From the dropdown select “Azure Blob Storage” as shown below

![](https://cdn-images-1.medium.com/max/2000/1*aZrQFeQpdOJFfFrQdP-k_g.png)

The **Connect Your Data** tab should follow the following rules

![](https://cdn-images-1.medium.com/max/2000/1*PGAUIpcXVLgcRrxNzx8Kdw.png)

The **Add Cognitive Skills** tab should follow the following rules

![](https://cdn-images-1.medium.com/max/2000/1*odVUMtVfEjOwGN9ODnnQOA.png)

The **Add Customized Target Indexer** tab should follow the following rules

![](https://cdn-images-1.medium.com/max/2000/1*4NpJutY59A0KobOORqPcVw.png)

Click on Submit to initiate the creation of the data source, skillset, index, and indexer.

## Test the Indexer

Towards the top of your Azure AI Search resource’s Overview page, opt for Search Explorer. Within Search Explorer, input * (a single asterisk) into the Query string box, then proceed to click on the Search button.

### Test Case 1: Fetch all

This query retrieves all documents in the index in JSON format.

![](https://cdn-images-1.medium.com/max/2210/1*exXFsu8J3wxNW3i0zLXsMg.png)

### Test Case 2: Include count

Above the search results, you’ll find a count indicating the number of documents returned by the search.

![](https://cdn-images-1.medium.com/max/2102/1*L3cnNuVJIx9vR8kp38PCgg.png)

### Test Case 3: Search specific keywords

This search locates documents containing references to “New York” within any searchable fields and provides the document’s filename along with its key phrases.

![](https://cdn-images-1.medium.com/max/2170/1*8Rv5u407hcveSXZeyKuycw.png)

### C# Programming🚀

Thank you for being a part of the C# community! Before you leave:

#### If you’ve made it this far, please show your appreciation with a clap and follow the author! 👏️️

Follow us: [X](https://twitter.com/sukhsukhpinder) | [LinkedIn](https://www.linkedin.com/in/sukhpinder-singh/) | [Dev.to](https://dev.to/ssukhpinder) | [Hashnode](https://dotnet.hashnode.dev/) | [Newsletter](https://www.linkedin.com/newsletters/net-programming-7031098498754195456/) | [Tumblr](https://www.tumblr.com/settings/blog/codewithsukh)

Visit our other platforms: [GitHub](https://github.com/ssukhpinder) | [Instagram](https://www.instagram.com/codewithsukh/) | [Tiktok](https://www.tiktok.com/@codewithsukh) | [Quora](https://www.quora.com/profile/Sukhpinder-Singh-4) | [Daily.dev](https://app.daily.dev/devcard)

More content at [C# Programming](https://medium.com/c-sharp-progarmming)