All guides
Practice now
D2 · Implement AI solutions with Microsoft Foundry

Generative AI apps and agents with Microsoft Foundry

This is the skill with the most exam questions: "Implement generative AI apps and agents by using Foundry". It covers everything from designing a prompt to deploying a complete agent — all within the same portal and SDK.

System and user prompts

An effective prompt separates two clear roles. The exam expects you to recognize which is which.

System prompt

Sets the role, tone, and rules the model must follow throughout the entire conversation. Configured once per deployment or agent.

E.g.: "You are a technical support assistant. Only answer about company products. If you don't know the answer, say so."

User prompt

The user's specific request at each turn of the conversation. It changes with every interaction.

E.g.: "How do I restart my router?"

Prompt best practices

Be specific about the expected output format, give examples (few-shot) when the task is ambiguous, and use the system prompt for scope boundaries — not for complex business logic.

Deploy and test in the portal

The simplest flow in requires no code: choose a model from the catalog, deploy it, and test it directly in the portal.

1

Create or open a project in the Foundry portal (ai.azure.com).

2

Choose a model from the model catalog and deploy it (deployment).

3

Open the Playground and interact with the model using test prompts.

4

Adjust the system prompt and parameters (temperature, max tokens) until you get the expected behavior.

Foundry SDK — lightweight client

The Foundry SDK is a thin client that exposes all of the project's APIs through a single endpoint. Higher-level SDKs — like Agent Framework — are built on top of the Foundry SDK, not as a replacement for it.

A lightweight chat client built with the Foundry SDK follows this pattern, at a high level:

// Pseudocode — general Foundry SDK pattern

client = FoundryProjectClient(endpoint, credential)

chat = client.get_chat_client(deployment_name)

response = chat.complete(messages=[system_prompt, user_prompt])

The exam doesn't test exact code syntax — it tests whether you recognize the pattern: a project endpoint, a deployment, and a chat/completion call.

Portal Agents vs Hosted Agents

Microsoft Foundry offers two ways to build an agent. The exam clearly distinguishes between the two.

Portal Agents

  • Defined in the portal (or via SDK/REST) without writing infrastructure code
  • Foundry runs them — there is no compute to manage and no containers to optimize
  • Ideal for a single-purpose ("single-agent") agent

Hosted Agents

  • Your own code, written with Agent Framework, LangGraph, OpenAI Agents SDK, or another framework
  • Packaged as a container and runs on an endpoint managed by Foundry
  • Gives full control over the agent's logic — in exchange for more maintenance responsibility

Exam key point

If the scenario says "no infrastructure to manage" or "built in the portal" → Portal Agent. If it says "own code packaged" or "agent framework" → Hosted Agent.

Building a client for the agent

Once the agent exists (Portal Agent or Hosted Agent), a lightweight app can consume it by calling its endpoint through the Foundry SDK — the same client pattern changes little, regardless of whether the agent runs code-free or with your own code behind it.

Common exam traps

❓ Does a Portal Agent require you to manage compute?

No. Foundry runs it directly — that's the key difference from a Hosted Agent, which does run on an endpoint managed by your own container.

❓ Does the Foundry SDK replace frameworks like Agent Framework?

No. The Foundry SDK is the base layer (thin client, a single project endpoint). Higher-level frameworks are built on top of it to provide additional orchestration capabilities.

❓ Does the system prompt change with every user message?

No. The system prompt is configured once to set the role and rules. The user prompt is what changes with every turn of the conversation.

Did you get this topic?

Test what you just learned

A team wants to launch a single-purpose support agent as soon as possible, without spending time managing infrastructure or containers. Which Microsoft Foundry approach fits best?

Ready to test "Apps and agents with Foundry — prompts, SDK, Portal Agents"?

Put what you learned to the test with original AI-901 exam questions.

Start AI-901 mock exam

Unlimited mock exams with the Pro plan

Log in to track your progress.