1---2name: azure-openai3description: Use when integrating Azure OpenAI Service, deploying GPT/embedding models, building RAG applications with Azure AI Search, implementing prompt engineering patterns, or studying for Azure AI Engineer Associate (AI-102) or AI-200.4---56# Azure OpenAI78## When to Use9- Deploying and integrating GPT-4o, GPT-4, GPT-3.5-turbo, or embedding models on Azure10- Building RAG (Retrieval-Augmented Generation) pipelines with Azure AI Search11- Designing prompt engineering patterns (system messages, few-shot, chain-of-thought)12- Implementing Responsible AI with Content Safety filtering13- Choosing between standard and provisioned deployment for throughput requirements14- Preparing for Azure AI Engineer Associate (AI-102) or AI-200 exam1516## Core Jobs1718### 1. Model Deployment19| Model Family | Use Case |20|--------------|---------|21| **GPT-4o** | Latest multimodal; text + vision; balanced cost/performance |22| **GPT-4** | High-quality reasoning; complex tasks |23| **GPT-3.5-turbo** | Fast, cost-effective; simple tasks, high volume |24| **text-embedding-ada-002 / text-embedding-3-*** | Vector embeddings for semantic search |25| **DALL-E 3** | Image generation from text |26| **Whisper** | Speech-to-text transcription |2728- Deployment types:29 | Type | Throughput | Billing | Best For |30 |------|-----------|---------|---------|31 | **Standard** | Shared; TPM/RPM limits | Pay-per-token | Variable workloads |32 | **Provisioned (PTU)** | Reserved capacity | Hourly PTU rate | Predictable, high-throughput |33 | **Global Standard** | Globally routed | Pay-per-token | Overflow capacity |3435- TPM = Tokens Per Minute; RPM = Requests Per Minute; quotas per deployment per region3637### 2. RAG (Retrieval-Augmented Generation)38- Pattern: User query → retrieve relevant chunks → pass as context to LLM → generate grounded response39- Azure implementation:40 1. **Document ingestion**: chunk documents → generate embeddings → index in Azure AI Search41 2. **Retrieval**: embed user query → search AI Search (vector, keyword, or hybrid) → return top-k chunks42 3. **Generation**: send chunks + query to Azure OpenAI → GPT generates answer citing retrieved context43- Azure AI Search capabilities:44 - **Vector search**: cosine similarity on embedding vectors45 - **Keyword search**: BM25 full-text search46 - **Hybrid search**: combine vector + keyword scores (recommended)47 - **Semantic ranking**: rerank hybrid results using language understanding48- Chunking strategy: fixed-size (tokens), sentence-based, or semantic chunking; overlap recommended4950### 3. Prompt Engineering Patterns51| Pattern | Description | When to Use |52|---------|-------------|------------|53| **System message** | Persona, instructions, constraints | Always; sets model behavior |54| **Few-shot examples** | Input-output examples in prompt | Specific output format required |55| **Chain-of-thought** | "Think step by step" instruction | Complex reasoning tasks |56| **JSON mode** | `response_format: {type: "json_object"}` | Structured output for parsing |57| **Tool/function calling** | Define functions; model decides to call | Agent-style applications |5859- System message persists across conversation turns; user/assistant messages are conversation history60- Temperature: 0 = deterministic; 1+ = creative; use 0 for RAG grounding, 0.7 for creative tasks61- Max tokens: limit output length; prevent runaway token consumption6263### 4. Content Safety64- **Azure AI Content Safety** = content moderation for inputs and outputs65- Content filters applied by default; categories: Hate, Violence, Sexual, Self-Harm66- Severity levels: Safe, Low, Medium, High; configurable threshold per category (requires approval)67- **Custom blocklist**: add domain-specific prohibited terms68- **Groundedness detection**: detect hallucinations (responses not grounded in retrieved context)69- **Prompt Shield**: detect jailbreak attempts and indirect prompt injection70- All content safety events logged; reviewable in Azure AI Studio7172### 5. Function Calling / Tools73- Define JSON schema of available functions; model includes function call in response when appropriate74- Client-side execution: parse model's function call → execute → return result → model generates final answer75- Use cases: search the web, query database, get current time, call external API76- **Parallel function calling**: model can call multiple functions in one response (GPT-4o, GPT-4-turbo)77- `tool_choice: "auto"` = model decides; `"required"` = must call a tool; specific tool name = force specific tool7879### 6. Fine-Tuning80| Aspect | Detail |81|--------|--------|82| Available models | GPT-4o mini, GPT-3.5-turbo |83| Data format | JSONL with `{messages: [{role, content}]}` per example |84| Min training examples | 10 (recommended: 50-100+) |85| Use case | Domain-specific tone/format; not for adding new knowledge |8687- Fine-tuning ≠ RAG: fine-tuning adjusts model behavior/style; RAG provides retrieval-time knowledge88- Rule of thumb: try prompt engineering + few-shot first; fine-tune only when prompt alone is insufficient89- Fine-tuned model deployed like standard model; billed per token + training compute9091## Key Concepts92- **PTU (Provisioned Throughput Units)** — reserved capacity; predictable latency; no rate limits during reservation93- **RAG** — retrieval at inference time; grounds model in current data; no retraining needed94- **Vector search** — cosine similarity on embeddings; finds semantically similar content95- **Hybrid search** — vector + keyword combined; better retrieval quality than either alone96- **System message** — model persona and instructions; persists across all turns in a conversation97- **Content filter** — default content safety filters; configure severity thresholds per category98- **JSON mode** — force model to output valid JSON; always include JSON instruction in system/user message99100## Checklist101- [ ] Azure OpenAI (not direct OpenAI API) used for enterprise compliance and private networking?102- [ ] PTU deployment evaluated for predictable high-throughput workloads?103- [ ] RAG implemented with Azure AI Search hybrid search + semantic ranking?104- [ ] System message crafted with clear persona, instructions, and constraints?105- [ ] Content Safety filters reviewed and custom blocklist configured for domain?106- [ ] JSON mode used for structured output instead of prompt-only JSON instructions?107- [ ] Private endpoint configured on Azure OpenAI resource for VNet isolation?108109## Output Format110- 🔴 **Critical** — Azure OpenAI public endpoint used for sensitive data without Private Endpoint111- 🔴 **Critical** — no content safety filtering on user-facing application (default filters disabled)112- 🟡 **Warning** — vector-only search without hybrid search (misses keyword-matched exact terminology)113- 🟡 **Warning** — temperature set to 1+ for RAG application (encourages hallucination; use 0 for grounding)114- 🟢 **Suggestion** — enable semantic ranking on Azure AI Search for best RAG retrieval quality115116## Exam Tips117- **Azure OpenAI ≠ OpenAI API** — Azure = enterprise features: private endpoints, RBAC, Entra ID auth, compliance certifications118- **PTU (Provisioned Throughput Units) = reserved capacity** — predictable latency; no rate limit surprises; billed hourly regardless of usage119- **RAG = retrieval + generation** — Azure AI Search provides retrieval (vector/hybrid); OpenAI generates grounded answer; no model retraining120- **Vector search = semantic similarity; keyword = exact match; hybrid = both** — hybrid recommended for RAG; semantic ranking reranks hybrid results121- **System message = persona + instructions; persists across turns** — always set for production apps; defines model's behavior throughout conversation122- **Responsible AI: content filters always on by default** — configure severity thresholds per category (requires Microsoft approval for lower thresholds)