How to Use Azure AI Search and Purview: A Complete Guide to Building a Sensitivity Label-Aware Secure RAG

2/25/2026
4 min read

How to Use Azure AI Search and Purview: A Complete Guide to Building a Sensitivity Label-Aware Secure RAG

Introduction

In the modern data management and search field, building a sensitivity label-aware secure RAG (Retrieval-Augmented Generation) system has become particularly important. RAG can combine the advantages of retrieval and generation to provide users with more accurate answers and information. In this article, we will guide you step by step on how to build a secure RAG system with sensitivity label awareness using Azure AI Search and Purview.

Prerequisites

Before you begin, please ensure you have the following:

  • Azure Account: You need a valid Azure account to access Azure AI Search and Azure Purview.
  • Basic Understanding of Azure Services: A basic understanding of Azure, including how to create resource groups and services.
  • Programming Basics: Some examples in this article may require basic knowledge of Python or PowerShell programming.
  • Detailed Steps

    Step 1: Create Azure AI Search Service

  • Log in to Azure Portal.
  • Click on "Create a resource" in the left menu.
  • Type "Azure Search" in the search box, select "Azure Cognitive Search," and then click "Create."
  • Fill in the necessary information such as name, subscription, resource group, and location, then click "Review + Create."
  • After confirming the information is correct, click "Create."
  • After creating the Azure AI Search service, you can find the relevant service information in the portal.
    

    Step 2: Create Azure Purview Account

  • Log in to Azure Portal.
  • Click on "Create a resource."
  • Type "Purview" in the search box, then select "Azure Purview."
  • Fill in the necessary information such as account name, subscription, resource group, and region, then click "Review + Create."
  • Wait for the resource deployment to complete.
  • The Purview service can help you manage the classification and sensitivity labels of your data.
    

    Step 3: Configure Data Sources and Sensitivity Labels

  • In the Azure Purview portal, click on "Data Sources."
  • Select "Add Data Source," enter the relevant information, and connect to your data source.
  • Configure data scanning. You can choose automatic or manual scanning.
  • In data classification, customize sensitivity labels such as: personal data, financial information, confidential data, etc.
  • With Purview, you can easily manage the sensitivity labels of your data.
    

    Step 4: Integrate Azure AI Search

  • Create a new index in the Azure Search service by configuring the index through REST API or SDK.
  • Create the index in the Azure Portal by defining fields, data types, and other parameters to configure the index.
  • {
    

    "name": "sample-index", "fields": [ {"name": "id", "type": "Edm.String", "key": true, "searchable": true}, {"name": "content", "type": "Edm.String", "searchable": true} ] }

  • Use the SDK to load data into the search index.
  • Step 5: Build RAG Request Processing Logic

  • Use Azure Functions or App Services to create an API interface that receives user query requests.
  • In this interface, implement the logic for sensitivity label checks.
  • import requests
    

    def querysearch(query): # Implement sensitivity label checks here and access the search API based on the check results. response = requests.get(f"?q={query}") return response.json()

    Step 6: Return Processed Response

    After processing the query, retrieve information from the search index and return it to the user, ensuring that the output does not disclose any sensitive information.

    def processresponse(response):
    

    results = response.get('value', []) # Process search results, filtering out sensitive information. return results

    Frequently Asked Questions

  • How to ensure data security?
  • - Use Azure Purview's sensitivity label management features to ensure strict control over sensitive information.

  • How to handle sensitive information in user queries?
  • - Implement a sensitivity label check mechanism in the query logic to handle accordingly based on labels, such as masking certain data.

  • What types of data sources can be used?
  • - Azure Purview supports various data sources, including Azure Blob Storage, SQL databases, etc.

    Conclusion

    Building a sensitivity label-aware secure RAG system requires a certain level of technical foundation, but by following the steps outlined above, you can leverage Azure AI Search and Purview to create an efficient and secure information retrieval system. Through effective data management and sensitivity label control, ensure that the information you handle remains secure and compliant. We hope this guide can help you!

    Published in Technology

    You Might Also Like