Question 925 of 988
Implement generative AI solutionseasyMultiple ChoiceObjective-mapped

Quick Answer

The correct approach is to include a system message that instructs the model to generate secure code following best practices. This works because Azure OpenAI’s system message sets the top-level context and behavioral guardrails for every response, allowing you to guide code generation output at inference time without needing post-processing or retraining. On the Microsoft Azure AI Engineer Associate AI-102 exam, this concept tests your understanding of how to steer model behavior declaratively rather than through complex validation pipelines—a common trap is assuming you must sanitize output after generation, which is less efficient and scalable. Remember that system messages are persistent instructions that shape the model’s entire conversation, making them the most direct tool for enforcing security policies like OWASP Top 10. Memory tip: think of the system message as the “constitution” for your AI—set the rules once, and every response follows them.

AI-102 Implement generative AI solutions Practice Question

This AI-102 practice question tests your understanding of implement generative ai solutions. Match the stated requirement to the specific cloud service, access model, or configuration option — many options are valid in isolation but not for this scenario. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

Your company wants to use Azure OpenAI to generate code snippets. You need to ensure the generated code does not contain security vulnerabilities. Which approach should you take?

Question 1easymultiple choice
Full question →

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 a system message that instructs the model to generate secure code following best practices.

Option B is correct because Azure OpenAI's system messages allow you to set the context and behavior of the model, including instructing it to follow secure coding best practices (e.g., OWASP Top 10). This is the most direct and scalable way to influence the model's output at inference time without requiring post-processing or retraining. The system message acts as a persistent instruction that guides every response, making it the recommended approach for steering content generation.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Scan the generated code with a static analysis tool after generation.

    Why it's wrong here

    Post-processing is good but not the primary approach for prevention.

  • Include a system message that instructs the model to generate secure code following best practices.

    Why this is correct

    System messages can guide the model to produce secure code.

    Related concept

    Read the scenario before looking for a memorised answer.

  • Use content filters to block malicious code.

    Why it's wrong here

    Content filters are not designed to detect security vulnerabilities.

  • Fine-tune the model on a dataset of secure code examples.

    Why it's wrong here

    Fine-tuning may help but requires significant effort.

Common exam traps

Common exam trap: answer the scenario, not the keyword

Microsoft often tests the misconception that content filters can handle security vulnerabilities, but content filters are for policy compliance (e.g., hate speech, violence), not for code security flaws like injection attacks or improper error handling.

Detailed technical explanation

How to think about this question

Under the hood, system messages in Azure OpenAI are prepended to the conversation history and influence the model's token probability distribution at each generation step, effectively biasing the output toward the instructed behavior. A real-world scenario is using a system message like 'You are a security-focused developer. Always use parameterized queries, validate inputs, and avoid hardcoded secrets.' This approach works across all prompts without requiring additional infrastructure, unlike static analysis which only catches known patterns. The subtle behavior is that system messages can be overridden by user messages if not carefully crafted, so they should be placed at the start of the conversation with clear, authoritative language.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A cloud solutions architect for a retail company is evaluating services for a new workload. The correct answer here reflects best practice for the specific scenario described — not a general cloud recommendation. Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option. Cloud exam questions reward reading the constraint carefully: the same technology can be right or wrong depending on the use case.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related AI-102 practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Implement an agentic solution practice questions

Practise AI-102 questions linked to Implement an agentic solution.

Implement computer vision solutions practice questions

Practise AI-102 questions linked to Implement computer vision solutions.

Implement knowledge mining and information extraction solutions practice questions

Practise AI-102 questions linked to Implement knowledge mining and information extraction solutions.

Implement image and video processing solutions practice questions

Practise AI-102 questions linked to Implement image and video processing solutions.

Implement natural language processing solutions practice questions

Practise AI-102 questions linked to Implement natural language processing solutions.

Implement generative AI solutions practice questions

Practise AI-102 questions linked to Implement generative AI solutions.

Implement agentic AI solutions practice questions

Practise AI-102 questions linked to Implement agentic AI solutions.

Implement knowledge mining and document intelligence solutions practice questions

Practise AI-102 questions linked to Implement knowledge mining and document intelligence solutions.

Plan and manage an Azure AI solution practice questions

Practise AI-102 questions linked to Plan and manage an Azure AI solution.

Implement content moderation solutions practice questions

Practise AI-102 questions linked to Implement content moderation solutions.

AI-102 fundamentals practice questions

Practise AI-102 questions linked to AI-102 fundamentals.

AI-102 scenario practice questions

Practise AI-102 questions linked to AI-102 scenario.

Practice this exam

Start a free AI-102 practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this AI-102 question test?

Implement generative AI solutions — This question tests Implement generative AI solutions — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: Include a system message that instructs the model to generate secure code following best practices. — Option B is correct because Azure OpenAI's system messages allow you to set the context and behavior of the model, including instructing it to follow secure coding best practices (e.g., OWASP Top 10). This is the most direct and scalable way to influence the model's output at inference time without requiring post-processing or retraining. The system message acts as a persistent instruction that guides every response, making it the recommended approach for steering content generation.

What should I do if I get this AI-102 question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

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 →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

5 more ways this is tested on AI-102

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. A company uses Azure OpenAI to generate code snippets. They notice that the model sometimes produces code that uses deprecated APIs. They want to minimize this without retraining the model. What should they do?

medium
  • A.Fine-tune the model on a dataset of recent code.
  • B.Set the temperature parameter to 0 to reduce randomness.
  • C.Add a system message instructing the model to use only current, non-deprecated APIs.
  • D.Provide a few-shot example of correct code in the prompt.

Why C: Option C is correct because adding a system message in Azure OpenAI allows you to set high-level instructions that guide the model's behavior without retraining. By explicitly instructing the model to use only current, non-deprecated APIs, you leverage the system prompt's ability to influence output style and content, effectively reducing deprecated API usage in generated code snippets.

Variation 2. A developer uses the Azure OpenAI SDK to generate code snippets. The generated code sometimes contains security vulnerabilities. What is the most effective way to mitigate this risk?

medium
  • A.Set the temperature parameter to 0 to make the output deterministic.
  • B.Post-process the generated code using a static code analysis tool.
  • C.Fine-tune the model on a dataset of secure code examples.
  • D.Include a system message that instructs the model to avoid insecure coding patterns.

Why D: Option D is correct because a system message sets the behavioral context for the model at inference time, instructing it to avoid insecure coding patterns without requiring retraining. This is the most direct and effective mitigation as it leverages the model's instruction-following capability to reduce vulnerabilities in generated code, aligning with Azure OpenAI's content filtering and safety system guidance.

Variation 3. A developer uses the Azure OpenAI API to generate code. They want to ensure that the generated code is in Python. Which parameter should they set?

medium
  • A.temperature
  • B.max_tokens
  • C.system message
  • D.top_p

Why C: The system message parameter in the Azure OpenAI API is used to set the behavior and context of the assistant, including specifying the desired output format or language. By setting the system message to something like 'You are a helpful assistant that always generates Python code,' the developer can instruct the model to produce Python code consistently. This is the correct parameter for guiding the model's response style and content.

Variation 4. A developer uses the Azure OpenAI API to generate code. They want to ensure that the generated code is in Python. Which parameter should they set?

medium
  • A.temperature
  • B.top_p
  • C.system message
  • D.max_tokens

Why C: The system message is used to set the behavior and context of the AI model, including specifying the desired output format or language. By setting the system message to 'You are a helpful assistant that always writes code in Python', the developer can instruct the model to generate Python code consistently. This parameter is part of the chat completions API and directly influences the model's persona and constraints.

Variation 5. You are using Azure OpenAI Service to generate code snippets for a development team. You notice that the generated code sometimes contains security vulnerabilities. You need to minimize the risk of generating insecure code while maintaining productivity. What should you do?

medium
  • A.Use system messages to instruct the model to prioritize security
  • B.Fine-tune the model on a dataset of secure code
  • C.Set the temperature parameter to 0
  • D.Disable content filtering to allow more flexibility

Why A: Option D is correct because system messages set the behavior of the model, instructing it to prioritize security. Option A is wrong because disabling content filtering would not address security vulnerabilities. Option B is wrong because fine-tuning requires labeled data and may not be practical. Option C is wrong because temperature affects creativity, not security.

Last reviewed: Jun 30, 2026

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.

Loading comments…

Sign in to join the discussion.

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.