Domain 2: Implement AI Solutions by Using Microsoft Foundry (Part 2 of 3)
This lesson covers 5 exam topics: Building a Client App for an Agent, Building a Text Analysis App, Responding to Spoken Prompts, Building a Speech App with Azure Speech, Interpreting Images with Multimodal Models. Each topic has a short video, then the notes: key facts, exam traps and what to check in the official docs.
1. Building a Client App for an Agent
Central question: How does an application talk to a Foundry agent?
Verified Python pattern
1project = AIProjectClient(endpoint=PROJECT_ENDPOINT, credential=DefaultAzureCredential())2openai = project.get_openai_client(agent_name=AGENT_NAME) # client bound to the agent3conversation = openai.conversations.create() # multi-turn history4r = openai.responses.create(conversation=conversation.id, input="What is the size of France?")5print(r.output_text)6r = openai.responses.create(conversation=conversation.id, input="And its capital?") # follow-up keeps contextAgents can also be defined in code: project.agents.create_version(agent_name=..., definition=PromptAgentDefinition(model=..., instructions=...)) (verified), useful for version control and CI/CD.
Key ideas
| Concept | Purpose |
|---|---|
| get_openai_client(agent_name=...) | Calls go to the named agent |
| Conversation | Keeps history across turns |
| responses.create | Sends a message, returns the agent's reply |
Exam traps
- New conversation each turn, losing context.
- Calling the model directly when the agent's tools and instructions are needed.
- Recreating the agent on every request. Create once; reuse.
2. Building a Text Analysis App
Central question: How do you add text analysis to an application?
Two ways (verified services; choice is design guidance)
| Approach | How | Fits |
|---|---|---|
| Azure Language | Client library (TextAnalyticsClient), REST, or Foundry playground; features such as PII, language detection, NER, sentiment | Consistent, typed results; built-in PII and entity categories |
| Generative model | Prompt a deployed model: "Return sentiment and key topics as JSON" | Flexible, custom categories, summaries |
Azure Language features are also available as tools via the Azure Language MCP server for agents (verified). Sentiment, key phrases and summarization are legacy Azure Language capabilities; PII, language detection and NER are core (verified).
App flow (general background)
Input text → call the service/model → parse results (labels, scores, entities) → act (route ticket, redact PII, chart sentiment).
Exam traps
- Generative model for strict PII redaction where a dedicated PII feature is more consistent.
- Ignoring confidence scores.
- No output format in the prompt, making parsing fragile.
3. Responding to Spoken Prompts
Central question: How does an app answer a user who speaks?
Options
| Option | How |
|---|---|
| Audio-capable multimodal model | Send audio as input; get text and/or audio out (e.g. gpt-4o-audio-preview, gpt-4o-mini-audio-preview) |
| gpt-realtime | Real-time interactive voice |
| Voice Live API | Fully managed low-latency speech-to-speech for voice agents; combines recognition, generative AI and synthesis |
| Voice-based prompt agent | Agent configured with model, instructions, audio settings and tools, connected through Voice Live |
| Pipeline | Speech to text → chat model → text to speech (Azure Speech) |
Audio model modality combinations include audio in → text out (transcription) and audio in → text + audio out (spoken replies) (verified).
Exam traps
- Building a three-step pipeline when one audio-capable model or Voice Live does it with less latency.
- Text-only chat model for audio input.
- Ignoring latency for live conversations; use real-time options.
4. Building a Speech App with Azure Speech
Central question: What code recognizes and synthesizes speech?
Verified Python patterns (azure-cognitiveservices-speech)
1import azure.cognitiveservices.speech as speechsdk2speech_config = speechsdk.SpeechConfig(subscription=KEY, endpoint=ENDPOINT)3 4# Speech to text5audio_config = speechsdk.audio.AudioConfig(use_default_microphone=True)6recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config, audio_config=audio_config)7result = recognizer.recognize_once_async().get()8print(result.text)9 10# Text to speech11speech_config.speech_synthesis_voice_name = "en-US-Ava:DragonHDLatestNeural"12synth = speechsdk.SpeechSynthesizer(speech_config=speech_config)13synth.speak_text_async("Your order has shipped.").get()| Object | Role |
|---|---|
| SpeechConfig | Credentials, endpoint, voice and language settings |
| AudioConfig | Microphone, speaker or file |
| SpeechRecognizer | Speech → text (recognize_once_async for one utterance) |
| SpeechSynthesizer | Text → speech (speak_text_async, or SSML) |
Exam traps
- Recognizer for synthesis (or vice versa).
- recognize_once for long recordings. Use continuous or batch transcription.
- No voice name, getting a default voice.
5. Interpreting Images with Multimodal Models
Central question: How do you ask a model about an image?
How
- Deploy a vision-enabled chat model and include the image in the message alongside text.
- Images are passed as an image URL or base64 data URL content part (
"type": "image_url"), together with a text part asking the question. - Set max tokens for the response length.
- Content filtering applies to vision requests.
Typical uses (general background)
Describe a photo; read text in an image; compare two product photos; analyze a damage photo for an insurance claim; interpret a chart.
Good practice (design guidance)
- Ask specific questions and request structured output.
- Combine with grounding (e.g. product catalog) to avoid guesses.
- Review outputs for high-stakes decisions.
Exam traps
- Text-only model with an image. It must be vision-enabled.
- Expecting exact bounding boxes from a chat model; use detection-specific tools for that.
- No question in the prompt, only an image.
References
- AI-901 study guide — checked Oct 21, 2026
- Quickstart: prompt agent — checked Oct 21, 2026
- Azure Language overview — checked Oct 21, 2026
- Sentiment quickstart — checked Oct 21, 2026
- Audio generation quickstart — checked Oct 21, 2026
- Voice Live — checked Oct 21, 2026
- Agents in Foundry — checked Oct 21, 2026
- Speech to text quickstart — checked Oct 21, 2026
- Text to speech quickstart — checked Oct 21, 2026
- What is Azure Speech — checked Oct 21, 2026
- Use vision-enabled chat models — checked Oct 21, 2026
Check your understanding
How does a follow-up keep context?Show answerHide answer
Answer
Same conversation ID.Redact names and phone numbers from chats?Show answerHide answer
Answer
Azure Language PII detection.Model accepting spoken questions and replying in speech?Show answerHide answer
Answer
An audio-capable model (e.g. gpt-4o-audio-preview).Object that turns text into audio?Show answerHide answer
Answer
SpeechSynthesizer.How is an image included in a chat request?Show answerHide answer
Answer
As an image_url content part (URL or base64).