Question 283 of 945
AI-102 Implement generative AI solutions Practice Question
A developer is using Azure OpenAI to generate code snippets. The developer needs to ensure that the generated code does not contain security vulnerabilities. Which TWO actions should the developer take? (Choose two.)
⚠ Common exam trap
The trap here is that candidates often overestimate the effectiveness of system messages (Option E) or content filtering (Option D) for code security, while underestimating the power of few-shot prompting (Option A) to directly influence model behavior through example-based guidance.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Include examples of secure coding practices in the prompt.
Including examples of secure coding practices in the prompt (few-shot prompting) directly guides the model to follow those patterns, reducing insecure code generation. Option D is also correct because Azure OpenAI's content filtering feature can be configured to block code patterns that match known vulnerabilities (e.g., SQL injection, buffer overflows), providing an additional safety layer. Options B (high max_tokens), C (fine-tuning on insecure code), and E (system message) are not effective or counterproductive.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Include examples of secure coding practices in the prompt.
Why this is correct
Providing examples of secure code helps guide the model towards generating secure code.
- ✗
Set the max_tokens parameter to a high value to allow longer outputs.
Why it's wrong here
Increasing max_tokens does not affect the security of the generated code.
- ✗
Fine-tune the model on a dataset containing examples of insecure code.
Why it's wrong here
Fine-tuning on insecure code would teach the model to produce more vulnerabilities.
- ✓
Use the content filtering feature to block malicious code patterns.
Why this is correct
Content filtering can be configured to detect and block common insecure code patterns.
- ✗
Add a system message that instructs the model to never generate insecure code.
Why it's wrong here
System messages can provide guidance but do not guarantee compliance, and the model may still generate insecure code.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Last reviewed: Jun 11, 2026
This AI-102 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AI-102 exam.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.