Skip to main content

Generative AI Apps & Agents with Foundry

Exam objectives:

  • Create effective system and user prompts for generative AI models
  • Deploy a model and interact with it in the Foundry portal
  • Create a lightweight chat client application using the Foundry SDK
  • Create and test a single-agent solution in the Foundry portal
  • Create a lightweight client application for an agent

Overviewโ€‹

The largest and most heavily tested area of AI-901 is building generative AI applications and agents using Microsoft Foundry (Azure AI Foundry). You need to be able to perform these tasks in the portal and understand the Python SDK code that powers client applications.

Key Conceptsโ€‹

The Foundry Workflowโ€‹

1. Create an Azure AI Foundry project
โ†“
2. Deploy a model (model catalog โ†’ deploy)
โ†“
3. Test in the Foundry playground
โ†“
4. Build a client app using the Foundry SDK
โ†“
5. (Optional) Add tools โ†’ create an agent

Promptsโ€‹

TypeRoleExample
System promptSets the model's persona, tone, and constraints for the whole session"You are a helpful Azure certification tutor. Answer only questions about Azure."
User promptThe end-user's input"What is the difference between AI-901 and AI-102?"
Assistant messageA previous model response โ€” used in multi-turn conversationsโ€”

Effective prompt techniques:

  • Be specific and unambiguous
  • Provide context and examples (few-shot prompting)
  • Use the system prompt to constrain behavior
  • Break complex tasks into steps (chain-of-thought)

Chat Client App โ€” Foundry SDK Patternโ€‹

from azure.ai.inference import ChatCompletionsClient
from azure.ai.inference.models import SystemMessage, UserMessage
from azure.core.credentials import AzureKeyCredential

client = ChatCompletionsClient(
endpoint="https://<your-project>.services.ai.azure.com/models",
credential=AzureKeyCredential("<your-key>")
)

response = client.complete(
model="<deployment-name>",
messages=[
SystemMessage("You are a helpful assistant."),
UserMessage("Explain Azure AI Foundry in one sentence."),
],
temperature=0.7,
max_tokens=200,
)

print(response.choices[0].message.content)

Agentsโ€‹

An AI agent is a model + a set of tools that it can call to complete multi-step tasks.

ConceptDescription
ToolA function the agent can call โ€” e.g., search, run code, call an API
InstructionsA system-level prompt that defines the agent's goal and behavior
ThreadA conversation session with the agent
RunA single execution of the agent on a thread
# Agent client app pattern
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential

project_client = AIProjectClient(
endpoint="https://<your-project>.services.ai.azure.com",
credential=DefaultAzureCredential()
)

agent = project_client.agents.get_agent("<agent-id>")
thread = project_client.agents.create_thread()
project_client.agents.create_message(thread.id, role="user", content="What is today's weather?")
run = project_client.agents.create_and_process_run(thread.id, agent.id)
messages = project_client.agents.list_messages(thread.id)
print(messages.data[0].content[0].text.value)

Azure Services & Foundry Featuresโ€‹

FeatureWhere in FoundryPurpose
Model catalogFoundry portal โ†’ Model catalogBrowse and deploy models
PlaygroundFoundry portal โ†’ PlaygroundTest prompts interactively
AgentsFoundry portal โ†’ AgentsBuild and test single-agent solutions
Foundry SDKazure-ai-inference, azure-ai-projects packagesBuild client apps in Python

Study Resourcesโ€‹