This section provides condensed implementation details for code completion and drag-and-drop questions. Memorize the Required columns.
SDK Packages and Classes
| Service | Package | Primary Class |
|---|
| Azure OpenAI | openai | AzureOpenAI |
| AI Vision | azure-ai-vision-imageanalysis | ImageAnalysisClient |
| AI Language | azure-ai-textanalytics | TextAnalyticsClient |
| AI Speech | azure-cognitiveservices-speech | SpeechConfig, SpeechRecognizer, SpeechSynthesizer |
| Document Intelligence | azure-ai-documentintelligence | DocumentIntelligenceClient |
| Content Safety | azure-ai-contentsafety | ContentSafetyClient |
| AI Search | azure-search-documents | SearchClient, SearchIndexClient |
| CLU | azure-ai-language-conversations | ConversationAnalysisClient |
| Custom Vision | azure-cognitiveservices-vision-customvision | CustomVisionTrainingClient, CustomVisionPredictionClient |
| Authentication | azure-identity | DefaultAzureCredential |
| Key Auth | azure-core | AzureKeyCredential |
Required Headers by Service
| Service | Required Headers |
|---|
| Most Azure AI Services | Ocp-Apim-Subscription-Key |
| Azure Translator | Ocp-Apim-Subscription-Key AND Ocp-Apim-Subscription-Region |
| Azure OpenAI | api-key |
| Azure AI Search | api-key |
Required vs. Optional Parameters
Azure OpenAI Chat Completions:
| Parameter | Required? | Default | Notes |
|---|
model | ✓ Yes | — | Deployment name |
messages | ✓ Yes | — | Array with role/content |
temperature | No | 1.0 | 0 = deterministic |
max_tokens | No | Model max | Limits response |
response_format | No | — | {"type": "json_object"} for JSON |
DALL-E Image Generation:
| Parameter | Required? | Default | Notes |
|---|
prompt | ✓ Yes | — | ONLY required parameter |
size | No | 1024x1024 | 1024x1024, 1792x1024, 1024x1792 |
quality | No | standard | standard, hd |
n | No | 1 | Max 1 for DALL-E 3 |
Content Safety:
| Parameter | Required? | Default | Notes |
|---|
text or image | ✓ Yes | — | Content to analyze |
categories | No | All four | Hate, Violence, Sexual, SelfHarm |
outputType | No | FourSeverityLevels | Severity granularity |
Code Completion Patterns
Pattern 1: Authentication Setup
from azure.identity import DefaultAzureCredential
from azure.core.credentials import AzureKeyCredential
Pattern 2: Azure OpenAI Client
from openai import AzureOpenAI
client = AzureOpenAI(
azure_endpoint=endpoint,
api_key=key,
api_version="2024-08-01-preview"
)
Pattern 3: Chat Completion
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": "You are helpful."},
{"role": "user", "content": "Hello"}
],
temperature=0.7
)
answer = response.choices[0].message.content
Pattern 4: Image Analysis
from azure.ai.vision.imageanalysis import ImageAnalysisClient
from azure.ai.vision.imageanalysis.models import VisualFeatures
client = ImageAnalysisClient(endpoint=endpoint, credential=credential)
result = client.analyze(
image_data=image_bytes,
visual_features=[VisualFeatures.CAPTION, VisualFeatures.READ]
)
Pattern 5: Document Intelligence
from azure.ai.documentintelligence import DocumentIntelligenceClient
client = DocumentIntelligenceClient(endpoint=endpoint, credential=credential)
poller = client.begin_analyze_document(
"prebuilt-invoice",
analyze_request=file_stream
)
result = poller.result()
Pattern 6: Speech-to-Text
import azure.cognitiveservices.speech as speechsdk
speech_config = speechsdk.SpeechConfig(subscription=key, region=region)
recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config)
result = recognizer.recognize_once()
text = result.text
Pattern 7: Text-to-Speech with SSML
speech_config.speech_synthesis_voice_name = "en-US-JennyNeural"
synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config)
result = synthesizer.speak_ssml_async(ssml_string).get()
Pattern 8: Azure AI Search
from azure.search.documents import SearchClient
from azure.search.documents.models import VectorizedQuery
search_client = SearchClient(endpoint, index_name, credential)
results = search_client.search(
search_text="query",
vector_queries=[VectorizedQuery(vector=embedding, k_nearest_neighbors=50, fields="contentVector")]
)
Container Deployment Quick Reference
docker run --rm -it -p 5000:5000 \
mcr.microsoft.com/azure-cognitive-services/{service}:{tag} \
ApiKey={KEY} \
Billing={ENDPOINT} \
Eula=accept
SSML Quick Reference
<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis"
xmlns:mstts="https://www.w3.org/2001/mstts" xml:lang="en-US">
<voice name="en-US-JennyNeural">
<prosody rate="slow" pitch="+5%">Slower, higher</prosody>
<break time="500ms"/>
<say-as interpret-as="date">2024-01-15</say-as>
<mstts:express-as style="cheerful">Happy tone!</mstts:express-as>
</voice>
</speak>
Decision Trees Quick Reference
Service Selection:
- Image input → Computer Vision / Custom Vision
- Audio input → Speech Services
- Text input → Language Services
- Document input → Document Intelligence
- Generate content → Azure OpenAI
Authentication:
- Development → API Key (
AzureKeyCredential)
- Production → Managed Identity (
DefaultAzureCredential)
Network:
- Development → Public endpoint
- Production (Azure only) → Private endpoint
Service Limits Quick Reference
Microsoft frequently tests knowledge of service limits and thresholds. Memorize these key values.
Input Size Limits:
| Service | Limit | Exam Relevance |
|---|
| Content Safety | 10,000 characters per request | Exceeding returns 400 error |
| Embeddings (ada-002) | 8,191 tokens per input | Longer text must be chunked |
| Document Intelligence | 500 MB per file, 2,000 pages max | Large docs need splitting |
| Azure AI Search | 16 MB per document | Index preprocessing required |
| Vision Image Analysis | 20 MB per image | Resize before processing |
| Speech STT | 60 seconds (single shot), 10 min (continuous) | Use continuous for long audio |
Training Minimums:
| Service | Minimum | Recommended |
|---|
| Custom Vision (per tag) | 5 images | 50+ images |
| CLU (per intent) | 1 utterance | 15+ utterances |
| Custom Speech | 30 minutes audio | 10+ hours audio |
| Custom Document Model | 5 documents | 50+ documents |
Quality Thresholds:
| Metric | Poor | Acceptable | Good | Excellent |
|---|
| BLEU Score (Translation) | <20 | 20-39 | 40-59 | 60+ |
| WER (Speech) | >30% | 15-30% | 5-15% | <5% |
| Confidence Threshold (typical) | — | 0.3-0.5 | 0.5-0.7 | 0.7+ |
Rate Limits:
| Service | Default TPM/RPM | Exam Pattern |
|---|
| Azure OpenAI GPT-4o | 80K TPM / 480 RPM | RateLimitError → backoff or quota increase |
| Azure OpenAI Embeddings | 350K TPM | Batch embedding → check rate limits |
| Content Safety | 1,000 requests/10 sec | Implement retry with Retry-After header |
⚠️ Exam Trap: These limits are testable—questions often present scenarios where exceeding a limit is the root cause of an error.
Common Errors Quick Reference
| Error | Service | Cause | Resolution |
|---|
RateLimitError | Azure OpenAI | Quota exceeded | Back off and retry; request quota increase |
InvalidPasswordProtectedDocument | Document Intelligence | Password-protected PDF | Remove password protection |
415 Unsupported Media Type | Vision, Document Intelligence | Wrong content type | Check supported formats |
401 Unauthorized | All services | Invalid/expired key | Regenerate key; check managed identity |
404 Not Found | All services | Wrong endpoint or deployment | Verify endpoint URL and deployment name |
400 Bad Request | All services | Malformed request | Check required parameters |
ContentFilterError | Azure OpenAI | Content blocked by safety | Adjust content filter settings |