Overview
This exercise demonstrates how to build a Retrieval Augmented Generation (RAG) chat application that integrates custom data sources into prompts for a generative AI model. The app is developed using Azure AI Foundry and deployed with Azure OpenAI and Azure AI Search.
Steps & Configuration Details
1. Create an Azure AI Foundry Hub and Project
- Open Azure AI Foundry portal (https://ai.azure.com) and create a hub project.
 - Configuration Items:
- Subscription: Your Azure subscription.
 - Resource Group: Select or create a resource group.
 - Hub Name: A valid name.
 - Location: Example values → East US 2, Sweden Central (quota limits may require a different region).
 
 
2. Deploy Models
Two models are required:
- Embedding Model → Converts text into vectors for indexing.
 - Generative AI Model → Answers user questions.
 
Deployment Settings:
- Embedding Model: 
text-embedding-ada-002 - Generative Model: 
gpt-4o - Deployment Type: Global Standard
 - Tokens Per Minute (TPM) Limit: 
50K(or the maximum available in your subscription) - Connected AI Resource: Link to Azure AI Foundry project
 - Content Filter: DefaultV2
 
3. Add Data to Your Project
- Download the data archive:
https://github.com/MicrosoftLearning/mslearn-ai-studio/raw/main/data/brochures.zip - Extract into a folder (
brochures) and upload it in Azure AI Foundry → Data + indexes. 
4. Create an Index in Azure AI Search
- Source Data: 
brochures - Index Configuration:
- Azure AI Search Resource: Create a new one.
 - Pricing Tier: Basic
 - Vector Index Name: 
brochures-index - Embedding Model Deployment: 
text-embedding-ada-002 - Search Method: Hybrid (vector + keyword)
 - OpenAI Connection: Default Azure OpenAI resource
 
 
5. Test the Index
- Open Chat Playground in Azure AI Foundry.
 - Submit: 
"Where can I stay in New York?" - Enable indexed data (
brochures-index) and rerun the query to check results based on RAG integration. 
6. Implement a RAG Client App
- Clone the GitHub repository:
rm -r mslearn-ai-foundry -f git clone https://github.com/microsoftlearning/mslearn-ai-studio mslearn-ai-foundry - Navigate to the project folder:
- Python: 
cd mslearn-ai-foundry/labfiles/rag-app/python - C#: 
cd mslearn-ai-foundry/labfiles/rag-app/c-sharp 
 - Python: 
 - Install dependencies:
- Python: 
pip install -r requirements.txt openai - C#: 
dotnet add package Azure.AI.OpenAI 
 - Python: 
 
7. Configure Connection Details
Edit the configuration file:
- Python: 
.env - C#: 
appsettings.jsonReplace placeholders with actual values: your_openai_endpointyour_openai_api_keyyour_chat_model(e.g.,gpt-4o)your_embedding_model(e.g.,text-embedding-ada-002)your_search_endpointyour_search_api_keyyour_index(e.g.,brochures-index)
8. Run the Chat Application
- Python: 
python rag-app.py - C#: 
dotnet run - Example prompt: 
"Where should I go on vacation to see architecture?" - Follow-up questions maintain chat history while utilizing the index for more context-aware responses.
 
9. Clean Up
To avoid unnecessary costs:
- Delete resources in Azure portal → Resource Group.