03 Create a Chat GPT-like application (RAG-based AI app) using Azure Services - Details Design
03 Create a ChatGPT-like application (RAG-based AI app) using Azure Services
๐งฉ 1. Clean Azure
Architecture (ChatGPT-style App)
6
๐ง How to read this:
Flow:
- User → Frontend (UI)
- Frontend → Backend API
- Backend → Azure AI Search (RAG)
- Backend → Azure OpenAI
- Response → User
๐️ Service Mapping
|
Layer |
Azure Service |
|
Frontend |
Azure Static Web Apps |
|
Backend |
Azure Functions / App Service |
|
AI Model |
Azure OpenAI Service |
|
RAG |
Azure AI Search |
|
Storage |
Blob Storage + Cosmos DB |
|
Security |
Microsoft Entra ID + Key Vault |
|
Monitoring |
Application Insights |
๐ ️ 2. Step-by-Step Build
Guide (Hands-On)
๐น Step 1: Create Azure
Resources
Go to Microsoft Azure Portal and
create:
- Azure OpenAI resource
- Azure AI Search
- Storage Account (Blob)
- Azure Functions
- Static Web App
๐น Step 2: Upload Your
Data (RAG Setup)
- Upload PDFs to Blob Storage
- Extract + chunk text (Python script)
- Generate embeddings using Azure OpenAI Service
- Store in Azure AI Search
๐น Step 3: Backend API
(Core Logic)
Example (Python - Azure Function):
def chat(req):
user_query = req.json["message"]
# 1. Search relevant docs
docs = search_index(user_query)
# 2. Build prompt
prompt = f"Answer using context:
{docs}\nQuestion: {user_query}"
# 3. Call OpenAI
response = openai.chat.completions.create(
model="gpt-4",
messages=[{"role": "user",
"content": prompt}]
)
return response.choices[0].message.content
๐น Step 4: Frontend
(Simple UI)
Use React:
- Input box (like ChatGPT)
- Call backend API
- Display response
Deploy via:
- Azure Static Web Apps
๐น Step 5: Add
Authentication
- Use Microsoft Entra ID
- Enable login (Google / Microsoft)
๐น Step 6: Store Chat
History
- Use Cosmos DB:
- user_id
- message
- response
๐น Step 7: Monitor
- Enable Azure Monitor
- Add logs + alerts
๐ฐ 3. Cost Estimate
(Realistic Monthly)
Here’s a starter-level
production estimate ๐
๐ง AI (Azure OpenAI)
- GPT-4 / GPT-4o usage
๐ ~$10 – $100/month (depends on usage)
๐ Azure AI Search
- Basic tier
๐ ~$75/month
๐พ Storage
- Blob Storage
๐ ~$5 – $20/month
⚙️ Backend
- Azure Functions (consumption plan)
๐ ~$0 – $20/month
๐ Frontend
- Static Web Apps
๐ Free tier available
๐งพ Database
- Cosmos DB
๐ ~$25 – $100/month
๐ Monitoring
- Application Insights
๐ ~$5 – $20/month
๐ต Total Estimate
|
Scale |
Monthly Cost |
|
๐งช Small (testing) |
$20 – $50 |
|
๐ Startup MVP |
$100 – $300 |
|
๐ข Production |
$500+ |
๐ง Final Insight (Very
Important)
๐ The most expensive
part is NOT Azure itself—it’s AI tokens
So optimize:
- Prompt size
- Retrieval quality (RAG)
- Caching responses
Comments
Post a Comment