Deploy and Call Models from Your App
30-second answer
You deploy a model in Microsoft Foundry, which creates a named deployment with a model version, a deployment type and capacity. Your app calls the deployment name, never the model name, through the project endpoint with AIProjectClient and DefaultAzureCredential. Choose a large or reasoning model for hard work, a small language model for cheap, high-volume work, a code model for programming tasks and a multimodal model when the input is an image or audio.
Exam objective: 2.1.1 Deploy and consume LLMs, small models, code models and multimodal models. 2.1.6 Configure an application to connect to a Foundry project. (Skills measured as of April 16, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
Open <strong>Build ➜ Models + endpoints</strong> and select <strong>+ Deploy model</strong>. A deployment is what your app calls.
👆 Click the glowing item in the portal to continue
Read the steps as text
- Open Build ➜ Models + endpoints and select + Deploy model. A deployment is what your app calls.
- Pick gpt-4.1-mini for general work. The deployment name is the name your code will use, so choose one that describes the job, not the model.
- Add a small language model for cheap, high-volume work such as labelling. Same project, a second deployment.
- Both deployments appear. Open support-chat to test it.
- In the chat playground pick the deployment, write instructions and ask a question. View code shows the same call as Python, using the project endpoint and keyless sign-in.
🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.
🖱️ Drag to rotate · scroll or pinch to zoom
Deploy a model, call the deployment
A deployment is a named copy of a model with a version, a deployment type and capacity. Your app calls the deployment name, never the model name. Pick a large model for hard work and a small language model for cheap, fast, simple work.
🤔 What happens if…
Read this tour as text
- Deploy a model, call the deployment. A deployment is a named copy of a model with a version, a deployment type and capacity. Your app calls the deployment name, never the model name. Pick a large model for hard work and a small language model for cheap, fast, simple work.
- RAG: retrieve first, then answer. Retrieval-augmented generation searches your own content (Azure AI Search, hybrid keyword plus vector), puts the best chunks in the prompt and asks the model to answer from them with citations. Without retrieval the model guesses.
- A multistep flow with checks. A workflow breaks one big request into steps you control: classify, extract to a JSON schema, call a tool, draft, then verify. Retries, fallbacks and a final check live in code, so one bad step can’t slip through unseen.
- Evaluate before you ship. Evaluators score each answer on a test set: groundedness (is it supported by the context?), relevance, coherence and safety checks. A fabrication shows up as a low groundedness score on one row, so you fix it before users see it.
- SDK, project endpoint and connections. The Foundry SDK (
azure-ai-projects) opens one door: AIProjectClient with the project endpoint and DefaultAzureCredential. From it your app gets an OpenAI-compatible client, deployments and connections (Azure AI Search, Application Insights) with no secrets in code. - Design the agent: role, goal, tool schema. An agent is a model plus instructions (role and goal), tools and a conversation (thread). A strict function schema names each parameter and marks the required ones, so the model asks the user instead of inventing a value.
- Retrieval, function calling and memory. One agent can use file search for documents, a function for live data and memory for what it learned about a user. The model asks to call a function; your code runs it and returns the result. Memory survives into a new conversation.
- Multi-agent orchestration. Several specialist agents can share a job. Sequential passes work down a line, concurrent fans out and merges, handoff moves control to the right specialist, group chat lets agents take turns in one shared conversation and Magentic lets a manager agent plan and delegate. Microsoft Agent Framework builds all five.
- Autonomy with approvals. Reads are safe, writes are not. A tool marked approval required pauses the run until a person decides. A hard limit in code blocks what no one should approve, whatever the model says.
- Monitor and debug agent runs. Agent evaluators read the whole run: intent resolution, tool call accuracy and task adherence. Error analysis groups the failing rows, such as a made-up tool argument, and points to the fix.
- Tune prompts and parameters. Instructions shape tone and rules, a few-shot example shows the format, temperature and top_p change how adventurous the wording is, and max output tokens caps length. A self-critique loop drafts, checks against a checklist and revises once.
- Trace every call and count tokens. OpenTelemetry spans record each agent run, model call and tool call, with tokens and latency, and Application Insights stores them. Tracing is opt-in, and recording message content is for development only because it captures prompts and answers.
- Route requests to the right model. A hybrid design puts rules first for answers code can decide, a small model for easy language work and a large or reasoning model only when needed. A model router can pick for you. Fewer big-model calls means a lower bill and faster replies.
Contoso Retail wants one app that sends hard questions to a large model and simple ones to a small one. Deploy both, find the project endpoint, call each deployment keylessly, and see what happens when the app passes a model name instead of a deployment name.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
Every call goes to the biggest model, and one deploy broke the app because it used the model name.
😊 THE SOLUTION
Deploy the right model for each job and have the app call the deployment name.
- Hard questions✓ A large or reasoning model deployment
- Thousands of simple labels✓ A small language model deployment
- A model upgrade breaks the app✓ Call the deployment name, so the model behind it can change
Start with a question
Why can a restaurant change its chef without reprinting the menu?
The menu says “today’s special”, not “Ravi’s special”. The kitchen decides who cooks it. Customers keep ordering the same way, and the chef behind it can change.
A deployment works like that menu line. Your app asks for support-chat. Behind the name sits one model, one version, one deployment type and a slice of capacity. Move the name to a new model next month and the app doesn’t change.
Explain it like I’m 10
The technical explanation
Pick the model for the job
| Need | Choose | Why |
|---|---|---|
| Hard, multistep problems, long documents | A large or reasoning model (gpt-4.1, o4-mini) | Better answers on difficult work, higher cost and latency |
| High-volume, simple tasks such as labelling | A small language model (Phi-4-mini-instruct, gpt-4.1-nano) | Fast and cheap |
| Writing and fixing code | A code-capable model | Trained on programming tasks |
| Images or audio as input | A multimodal model (gpt-4.1, Phi-4-multimodal-instruct) | Accepts more than text |
| Search and similarity | An embedding model (text-embedding-3-small) | Returns vectors, not text |
Test two candidates on your own examples before you decide. Benchmarks don’t know your tickets.
Deploy it
In the Foundry portal go to Build > Models + endpoints > + Deploy model. You choose the model, a deployment name, the deployment type (Global Standard, Data Zone Standard, Standard, Provisioned or Batch), the model version and the capacity in tokens per minute. From the CLI:
az cognitiveservices account deployment create -n contoso-agents -g rg-agents \
--deployment-name support-chat --model-name gpt-4.1-mini --model-format OpenAI \
--sku-name GlobalStandard --sku-capacity 50
Deployment names must be unique in the resource. Pick names that describe the job, such as support-chat or label-fast.
Call it from Python
Install the Foundry SDK, then connect with the project endpoint and a keyless credential. Both values come from the project Overview page, and the endpoint belongs in an environment variable, not in code.
# pip install "azure-ai-projects>=2.3.0" azure-identity
import os
from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient
project = AIProjectClient(endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
credential=DefaultAzureCredential())
openai = project.get_openai_client() # OpenAI-compatible client
r = openai.responses.create(model="support-chat", # the DEPLOYMENT name
input="In one sentence, why do apps call a deployment name?")
print(r.output_text, r.usage.input_tokens, r.usage.output_tokens)
The reply carries the token counts you pay for. To run this in Azure without a key, enable a managed identity on the host and give it the Foundry User role on the Foundry resource. Locally, DefaultAzureCredential uses your own sign-in.
Architect level Deployment types change where and how you pay
Global Standard and Data Zone Standard bill per token and differ in where the prompt may be processed: anywhere, or inside a data zone. Standard stays in one region. Provisioned reserves capacity for steady, latency-sensitive traffic, and Batch suits big offline jobs. You choose the type when you deploy, so a residency rule is a deployment decision, not a code change. Model versions can be pinned or set to upgrade automatically, as of 25 November 2026.
Real-world business scenario
Fabrikam Retail (fictional)
- The problem
- One app sent every request, even simple order-status labels, to the largest model. It was slow at peak, and a model upgrade once broke production because the code named the model.
- What they used
- Two Foundry deployments in one project: support-chat on gpt-4.1-mini for customer answers and label-fast on Phi-4-mini-instruct for ticket labels. The app calls the deployment names through AIProjectClient with a managed identity.
- Why that choice
- Simple work moves to the cheaper model, and a model change becomes a deployment change instead of a code change.
- The result
- Labelling got faster, the large model handled only what needed it, and the next model upgrade was done by repointing a deployment.
When to use it and when not to
✓ Use it when…
- You need a model reply inside your own app, with your own logic around it.
- Different tasks need different models, sizes or deployment types.
- You want keyless access that works on a laptop and in Azure.
✕ Think twice when…
- A prebuilt Foundry Tool already does the job, such as extracting invoice fields.
- Rules or a lookup table can answer exactly. Don't pay for a model call.
- You would paste a key into code. Use Microsoft Entra ID.
↔ Alternatives to consider
- Foundry Tools such as Content Understanding for predictable, structured extraction.
- Foundry Agent Service when the model needs tools, files and memory.
- Rules or code for exact answers.
Test yourself with exercises
5 original practice questions in the AI-103 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner Why does my app pass a deployment name and not a model name?
Model answer
The deployment is the thing that exists in your resource. It points to one model, one version, one deployment type and a slice of quota. If the app used the model name, you could never change the model behind it without editing code.
Intermediate How do you pick between a large model and a small one?
Model answer
I start from the task. Hard, multistep or long-document work goes to a large or reasoning model. Simple, high-volume work such as labelling goes to a small model. Then I test both on my own examples, because a small model that passes is much cheaper.
Experienced developer How should an app authenticate to a Foundry project from Azure?
Model answer
With a managed identity and Microsoft Entra ID. I enable the identity on the host, give it a Foundry role such as Foundry User on the resource, and use DefaultAzureCredential, so there is no key in code or configuration.
Scenario A call fails with DeploymentNotFound but the model is deployed. What do you check?
Model answer
I check the model parameter first. It must be the deployment name I chose, which might be support-chat, not gpt-4.1-mini. Then I check the endpoint is for the right project and the deployment is in that resource.
Quick revision
Key points
- A deployment holds the model, version, deployment type and capacity.
- Apps pass the deployment name in the model parameter.
- The project endpoint plus DefaultAzureCredential gives keyless access.
- Use small models for simple volume work and large or reasoning models for hard work.
- Multimodal models accept images or audio as input.
Important terminology
- Deployment
- A named copy of a model in a Foundry resource, with a version, a deployment type and a capacity. Apps call it by name.
- Project endpoint
- The URL an app uses to reach one Foundry project, shaped like https://<resource>.services.ai.azure.com/api/projects/<project>.
- Small language model (SLM)
- A compact model such as Phi-4-mini-instruct that is cheap and fast for simple, high-volume tasks.
- Multimodal model
- A model that accepts more than text, such as images or audio, as input.
- DefaultAzureCredential
- An Azure Identity credential that tries your sign-in locally and a managed identity in Azure, so code needs no key.
- Responses API
- The OpenAI-compatible API your app calls with the deployment name and an input to get a reply and token usage.
Common mistakes
- Passing the model name instead of the deployment name.
- Sending every request to the largest model.
- Pasting an API key into code when Entra ID works.
Exam tips
- "Cheapest model for simple, high-volume labelling" = small language model.
- "404 DeploymentNotFound" = the app used a model name, not the deployment name.
- "No secrets in code" = managed identity + DefaultAzureCredential.
Five quick revision questions
-
1.What does the app pass in the model parameter?Show
The deployment name.
-
2.What does AIProjectClient need?Show
The project endpoint and a credential.
-
3.Which model type reads photos?Show
A multimodal model.
-
4.Which model suits cheap simple labelling?Show
A small language model.
-
5.Which credential avoids keys?Show
DefaultAzureCredential.
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: Retrieval-Augmented Generation (RAG) in an App
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.