Generative Apps & RAG
Models & deployment types · RAG and Azure AI Search · function calling & multistep flows · evaluators · Foundry SDK, connections & project endpoint
By the tools4free.dev team · Last reviewed November 13, 2026
Practice questions for this topic →
Pick a model type and a deployment type
The Foundry catalog ranges from foundation models, reasoning models, small language models and multimodal models to domain-specific and industry models. Models sold by Azure come with Microsoft support; partner and community models are supported by their providers.
| Need | What the pages say |
|---|---|
| Small language model (edge or on-device) | Meta models include small language models (SLMs) like 1B and 3B Base and Instruct models for on-device and edge inferencing |
| Code model | The Codex variants (for example gpt-5.3-codex) are optimized for Codex CLI and the Codex VS Code extension |
| Multimodal (text and images) | GPT-4o integrates text and images in a single model; vision-enabled chat models answer questions about images through the Chat Completion API on a deployed model |
| Image from Azure Blob Storage by SAS URL | Enable Managed Identity and assign the Storage Blob Reader role to your Azure OpenAI resource |
| Deployment type | Where data is processed | Pick it when |
|---|---|---|
Global Standard (GlobalStandard) | Any Azure region | Default start for most workloads: newest models, lowest price, broadest regions |
| Data Zone Standard / Provisioned | Within the data zone (US, EU or APAC) | Processing must stay in a data zone |
| Standard / Regional Provisioned | Within the Azure geography | Geography compliance |
| Provisioned types | Global, data zone or geography | Consistent high volume; guaranteed throughput and lower latency variance |
| Global Batch / Data Zone Batch | Any region / within the data zone | Large jobs that aren't time-sensitive; 50% cost savings |
Developer (DeveloperTier) | Any Azure region | Fine-tuned model evaluation only; no SLA |
- Standard types offer best-effort service; provisioned types provide guaranteed throughput and lower latency variance.
- Deploy the same model more than once under different deployment names to test different configurations, including content filters.
- Managed compute bills virtual machine core hours; serverless deployments bill inputs and outputs, typically in tokens.
- Partner and community models require Azure Marketplace; models sold by Azure don't have that requirement.
az cognitiveservices account list-modelsshows each model'sname,format(the provider),versionand SKU; the deployment needs the Cognitive Services Contributor role or equivalent on the Foundry resource.
Retrieval-augmented generation (RAG)
RAG combines search with an LLM so responses are grounded in your data. Use it for private or frequently changing data.
- Retrieve: the app queries an index or data store for relevant content.
- Augment: the app combines the user's question and the retrieved grounding data into a prompt.
- Generate: the model answers from the augmented prompt, which reduces inaccuracies and enables citations.
| You need | Use |
|---|---|
| Answers grounded in private or frequently changing data | RAG |
| To change model behavior, style or task performance, not add fresh knowledge | Fine-tuning |
| An agent that gets retrieval as a tool | Agent tools (for example the file search tool) |
| A full RAG app with complete control | The Foundry SDK |
A typical Foundry RAG implementation: prepare and chunk your data, set up an index, connect the project to the index, build the app with the Foundry SDK or REST APIs, then test and evaluate.
| Retrieval option | How it works |
|---|---|
| Keyword, semantic, vector or hybrid index | The index is the data structure optimized for retrieval; Azure AI Search is a recommended index store for RAG |
| Hybrid search | One request with both search and vectorQueries; full-text and vector queries run in parallel and Reciprocal Rank Fusion (RRF) merges the results |
| Agentic retrieval | A model breaks a complex input into focused subqueries, runs them in parallel and returns structured grounding data; it uses conversation history |
| Symptom | Fix from the page |
|---|---|
| Poor retrieval quality | Review data chunking, embedding model quality and the search configuration (keyword, semantic or hybrid) |
| Hallucination despite grounding | Enable citations and use clear system messages that tell the model to stick to the retrieved content |
| Latency from large indexes | Use indexing strategy, filtering and re-ranking to reduce the passages processed |
| Token budget exceeded | Filter, rank or summarize passages |
- Vector search requires embeddings at indexing time, and often at query time; retrieved passages also add input tokens and cost.
- Apply access control at retrieval time; Azure AI Search supports document-level access control with security filters.
- Prefer Microsoft Entra ID over API keys for production, and treat retrieved content as untrusted input.
Tool-augmented flows and multistep pipelines
Function calling
- Call the chat completions API with your functions and the user's input.
- Use the model's response to call your API or function; your application runs the function.
- Call the API again with the function result to get the final response.
- The model decides whether to call a function from the context of the prompt; with
tool_choiceset toauto(the default) it picks the function itself. A named tool object forces one function. - In Chat Completions the
functionsandfunction_callparameters are deprecated; usetoolsandtool_choice. - Tool and function descriptions are limited to 1,024 characters; function definitions consume prompt tokens.
- Give each function and unclear parameter a meaningful description. If the model calls functions you didn't provide, add "Only use the functions you have been provided with." to the system message.
- Use least privilege (for example read-only database access), validate the calls the model generates, and add a user confirmation step for functions that take actions.
- Structured outputs make a model follow a JSON Schema you provide:
response_formatin Chat Completions,text.formatin Responses. The older JSON mode guaranteed valid JSON but not strict adherence to the schema.
How much orchestration
| Level | Use when |
|---|---|
| Direct model call | The model can do the task in one pass; if prompt engineering solves it you don't need an agent |
| Single agent with tools | Varied queries in one domain with dynamic tool use; often the right default; set iteration limits to guard against infinite tool-call loops |
| Multiagent orchestration | A single agent can't reliably handle the task because of prompt complexity, tool overload or security requirements; adds coordination overhead, latency and failure modes |
Breaking a task into smaller steps often improves results. A search call can be an affordance that mitigates fabricated answers and brings up-to-date information. Foundry workflows (UI-based, declarative sequences with branching and human-in-the-loop steps) are retiring on December 1, 2026; use Microsoft Agent Framework for new workflows.
Evaluate models and apps
An evaluation applies one or more evaluators to a dataset, generated responses, simulated conversations or production traces. Choose what to evaluate, select evaluators, run the evaluation (once, in CI/CD or recurring) and review results.
| Evaluator | Measures | Needs |
|---|---|---|
| Groundedness | Response aligns with the given context without fabricating content (precision) | LLM judge: deployment_name; response and context |
| Groundedness Pro (preview) | Strict consistency with the context, using Azure AI Content Safety; True/False | query, response, context; no model deployment |
| Relevance | Accuracy, completeness and direct relevance of the response to the query | query, response; no ground truth |
| Response Completeness (preview) | Whether the response misses critical information (recall) | ground_truth, response |
| Retrieval | How relevant the retrieved chunks are to the query (LLM judge) | query, context; no ground truth |
| Document Retrieval | Fidelity, NDCG, XDCG, Max Relevance and Holes against ground-truth labels | retrieval_ground_truth, retrieved_documents |
| Ungrounded Attributes | Fabricated or erroneous information inferred from user interactions | Risk and safety evaluator |
| Indirect Attack (XPIA) | Whether the response fell for an indirect jailbreak injected through retrieved context | Risk and safety evaluator |
- RAG evaluators return 1 to 5; the default pass threshold is 3.
- System evaluation judges the final response; process evaluation judges the retrieval step.
- A parameter sweep varies search algorithm,
top_kand chunk size and usesdocument_retrievalto find the best retrieval settings. - Combine for a RAG app: Retrieval + Groundedness + Relevance + Content Safety; add Hate and Unfairness, Sexual, Violence and Self-Harm evaluators for responsible AI.
- Set
evaluation_leveltoturn(default) orconversation; conversation level requires themessagesformat. - A cloud evaluation has three steps: define the data shape and evaluators, create the evaluation, then start a run, poll and get results. Results are stored in your Foundry project.
- The AI red teaming agent simulates attacks with PyRIT before deployment. Groundedness detection in Azure AI Content Safety retires on April 30, 2027.
Foundry SDKs, connections and the project endpoint
| Use | When |
|---|---|
| Foundry SDK | Apps with agents, evaluations or Foundry-specific features; one project endpoint |
| Agent Framework | Hosted agents or multi-agent systems in code (C#/.NET or Python) |
| LangChain Azure SDKs | Python agents and workflows with LangGraph, LangChain or Deep Agents |
| OpenAI SDK | Maximum OpenAI compatibility or lowest latency, embeddings, or Models sold by Azure through Chat Completions |
| Anthropic SDK | Anthropic Claude models deployed in Foundry |
| Foundry Tools SDKs | Specific AI services such as Vision, Speech and Language |
- Project endpoint format:
https://<resource-name>.services.ai.azure.com/api/projects/<project-name>; with a custom subdomain, use it in place of the resource name. - Two client types: the project client for Foundry-native operations (listing connections, project properties, enabling tracing) and the OpenAI-compatible client for the Responses API, agents, evaluations and fine-tuning. Most apps use both.
- Python:
azure-ai-projects2.x (>=2.3.0) is for the new Foundry (1.x is the classic Foundry package). Authenticate withDefaultAzureCredentialandaz login. - An Azure OpenAI resource provides only the
/openai/v1endpoint; API keys work on/openai/v1, but samples use Microsoft Entra ID. - Foundry User on the project is for day-to-day development; Foundry Project Manager manages a project and its connections; Foundry Account Owner on the resource creates projects.
- Connect an Azure AI Search index: Manage > Project details > Connected resources > Add connection, choose Azure AI Search and the authentication type. In code, resolve it with
project.connections.get(name)and useconnection.idasproject_connection_id. - The Azure AI Search tool targets one index (
top_kdefaults to 5). For keyless authentication use the Foundry account's system-assigned managed identity with Search Index Data Contributor and Search Service Contributor; a private virtual network needs managed identity, not keys.
CLI and PowerShell
| Task | Azure CLI | PowerShell |
|---|---|---|
| Install the Foundry SDK (Python) | pip install "azure-ai-projects>=2.3.0" "openai>=3.0.0" | - |
| Create the project client and the OpenAI-compatible client (Python) | project = AIProjectClient(
endpoint=project_endpoint,
credential=DefaultAzureCredential(),
)
openai = project.get_openai_client() | - |
| Call a model with the Responses API (Python) | response = openai.responses.create(
model="gpt-5-mini",
input="What is the size of France in square miles?",
) | - |
| Resolve a project connection (Python) | azs_connection = project.connections.get(SEARCH_CONNECTION_NAME) | - |
| Create a model deployment | az cognitiveservices account deployment create -n $accountName -g $resourceGroupName --deployment-name Phi-4-mini-instruct --model-name Phi-4-mini-instruct --model-version 1 --model-format Microsoft --sku-capacity 1 --sku-name GlobalStandard | - |
| Check a deployment is ready | az cognitiveservices account deployment show --name <resource-name> --resource-group <resource-group> --deployment-name gpt-5-mini --query properties.provisioningState --output tsv | - |
| Get a temporary token for the Foundry REST API | az account get-access-token --scope https://ai.azure.com/.default | - |
Exam Tips
Tick each tip once you can answer it without looking.
“A general workload with no data residency or throughput requirement needs a deployment type” → Global Standard. Trap: Standard is tied to an Azure geography, Provisioned reserves capacity you may not need, and Batch is for asynchronous jobs.
“Prompts and responses must be processed only within the EU, but you still want pay-per-token billing” → Data Zone Standard (Data Zone Provisioned if you also need reserved throughput). Trap: Global types may process data in any Azure region; Standard stays within one Azure geography.
“Large jobs that aren't time-sensitive, at lower cost” → Global Batch or Data Zone Batch (50% cost savings). Trap: Standard and provisioned types are for interactive traffic; Provisioned bills reserved capacity.
“Consistent high volume with low latency variance” → A provisioned deployment type. Trap: Standard types offer best-effort service; Global Standard suits variable, bursty traffic.
“Test two content filter settings on the same model” → Deploy the same model twice under different deployment names. Trap: A deployment name must differ; you don't need a different model.
“Answers from private or frequently changing data” → RAG: retrieve, augment, generate. Trap: Fine-tuning changes behavior, style or task performance; it doesn't add fresh knowledge.
“One request mixes full-text and vector queries over one index” → Hybrid search; RRF merges the two result sets. Trap: Vector search alone misses exact terms; agentic retrieval adds LLM-planned subqueries and is a different feature.
“A complex, multi-part question must be split into subqueries that run in parallel and use conversation history” → Agentic retrieval. Trap: Classic RAG uses a single query.
“The model returns a function name and arguments: who runs the function?” → Your application; it then sends the result back in a second call. Trap: The model doesn't execute functions; it only generates the call.
“Force one specific function to be called” → Set tool_choice to a named tool object. Trap: auto lets the model decide, and function_call is deprecated.
“Response must not contain content outside the grounding context (precision)” → Groundedness; Response Completeness covers recall against ground truth. Trap: Relevance judges whether the answer addresses the query, not whether it stays inside the context.
“Retrieval quality measured with human-labeled relevance (NDCG, Fidelity, Holes)” → Document Retrieval evaluator. Trap: The Retrieval evaluator uses an LLM judge and needs no ground truth, so it can't produce NDCG.
“Strict groundedness check powered by Azure AI Content Safety, no model deployment” → Groundedness Pro (preview); it returns True/False. Trap: Groundedness is an LLM-judge evaluator that needs deployment_name.
“Which SDK for apps with agents and evaluations behind one endpoint” → The Foundry SDK (project endpoint); OpenAI SDK for lowest latency or embeddings. Trap: An Azure OpenAI resource only gives /openai/v1.
“Which client calls responses.create against a Foundry project” → The OpenAI-compatible client from project.get_openai_client(). Trap: The project client is for Foundry-native operations such as connections.
“Agent search tool needs the connection to Azure AI Search” → project.connections.get(name).id as project_connection_id; one index only; managed identity if the search service is on a private network. Trap: Key-based authentication isn't supported with a private virtual network.
Sources
- Foundry Models overview
- Foundry Models sold by Azure
- Deployment types in Foundry Models
- Deploy models using Azure CLI and Bicep
- Vision-enabled chat models
- RAG and indexes in Microsoft Foundry
- Hybrid search overview
- RAG and generative AI in Azure AI Search
- Azure AI Search tool for agents
- Prompt engineering techniques
- Function calling
- Structured outputs
- AI agent orchestration patterns
- Build a workflow in Foundry
- Evaluation in Microsoft Foundry
- Observability in generative AI
- RAG evaluators
- Built-in evaluators reference
- Groundedness detection
- Cloud evaluation with the Foundry SDK
- Foundry SDKs and endpoints
- Quickstart: Get started with the Foundry SDK
- LangChain and LangGraph with Foundry
- Create projects
Checked against Microsoft Learn on November 13, 2026.