PromptisePromptise
PlatformSoonEnterprise
DocsGitHub
Talk to usGet started
Promptise - AI Framework LogoPromptise

The full-stack framework for agentic systems. Build with the framework. Run it on the platform. Launch it with our engineers.

pip install promptise

[01] Product

  • Framework
  • Platform (coming soon)
  • Enterprise
  • How it works
  • Contact

[02] Framework

  • The Agent
  • The Interface
  • The Harness

[03] Resources

  • Documentation
  • GitHub
  • Why Promptise
  • Use cases
  • Roadmap
  • Guides
  • Learning Paths
  • Questions

[04] Company

  • About
  • Terms of Service
  • Privacy Policy
  • Cookie Policy
  • Subprocessors

© 2026 Promptise by Manser Ventures. All rights reserved.

hello@promptise.com
← Learning paths> Agentic Engineering with Promptise Foundry
Lesson 12 / 100
12%

Azure OpenAI Agent with MCP: Use Deployments in Promptise

Build an Azure OpenAI agent with MCP tools: deployment vs model name, endpoint, API version or the v1 API, Entra ID sign-in, and fixes for common errors.

Beginner12 minModel Selection and RoutingModel Context Protocol (MCP)
All 100 lessons↓
  1. ✓What Is an AI Agent? Definition, How It Works, Examples
  2. ✓How to Build an AI Agent in Python (2026 Guide)
  3. ✓Build a Personal AI Agent: Memory, Reminders, Chat
  4. ✓What Is an Agent Harness? Parts and How to Build One
  5. ✓System Prompt Best Practices for AI Agents in Python
  6. ✓Best LLM for AI Agents (2026): Picks, Prices, How to Test
  7. ✓AI Agent YAML: Define and Run an Agent From a Config File
  8. ✓Streaming LLM Responses with FastAPI: Tokens and Tool Calls
  9. ✓Best Local LLM for AI Agents: Ollama Models by GPU (2026)
  10. ✓Claude AI Agent with MCP: Use Anthropic Models in Promptise
  11. ✓Gemini AI Agent with MCP: Use Google Models in Promptise
  12. 12Azure OpenAI Agent with MCP: Use Deployments in Promptise
  13. 13OpenRouter AI Agent with MCP: Many Models in Promptise
  14. 14Ollama AI Agent with MCP: Run Local Models in Promptise
  15. 15LLM Semantic Cache and Model Fallback in Python
  16. 16What Is MCP (Model Context Protocol)? A Developer's Guide
  17. 17What Is Tool Calling? LLM Function Calling Explained
  18. 18MCP Tools vs Resources vs Prompts (With Python Examples)
  19. 19How to Connect MCP Servers to Your AI Agent in Python
  20. 20Build a Production MCP Server in Python (Step by Step)
  21. 21MCP Transports: stdio vs Streamable HTTP vs SSE (Python)
  22. 22MCP 2026-07-28 Migration: Make Your MCP Server Stateless
  23. 23OpenAPI to MCP: Turn Any REST API into an MCP Server
  24. 24MCP Authentication in Python: API Keys, JWT and OAuth
  25. 25Build an Authenticated MCP Server for Your AI Agent (Python)
  26. 26MCP Security Best Practices: A Checklist for MCP Servers
  27. 27Testing MCP Servers in Python: pytest Without a Live Server
  28. 28Too Many MCP Tools? How to Fix LLM Tool Selection in Python
  29. 29Idempotent Tool Calls: Make AI Agent Retries Safe
  30. 30AI Agent Tool Failures: Stop Unsafe Workarounds
  31. 31MCP Server Caching, Timeouts and Circuit Breakers in Python
  32. 32MCP Middleware for Servers: Auth, Logging, Rate Limits
  33. 33MCP vs CLI for AI Agents: Tokens, Security, When to Use Each
  34. 34LangChain vs MCP: Differences and How They Work Together
  35. 35FastMCP Alternatives for Production MCP Servers (2026)
  36. 36AI Agent Audit Logging: Tamper-Evident Logs in Python
  37. 37AI Agent Human in the Loop: Approve Tool Calls in Python
  38. 38AI Agent Prompt Injection: How to Defend Against It
  39. 39Hidden Text Prompt Injection: Sanitize Pages for AI Agents
  40. 40Build a Multi-Agent System in Python (and When Not To)
  41. 41Context Engineering for AI Agents: Context Window Management
  42. 42Context Compaction for AI Agents: Trim vs Summarize
  43. 43How to Deploy an AI Agent with Docker (2026 Guide)
  44. 44LLM Tool Rate Limiting: Per-Client Limits for MCP Servers
  45. 45MCP Long-Running Tasks: Background Jobs in Python
  46. 46MCP Server Monitoring: Prometheus, OpenTelemetry and Logs
  47. 47Best AI Agent Frameworks (2026): Python Options Compared
  48. 48Self-Improving AI Agent: Learn From Tool Failures in Python
  49. 49AI Agent Identity: Authenticate Agents to MCP Servers
  50. 50Code-Action Agents in Python: One Program vs 37 Tool Calls
  51. 51Multi-Tenant AI Agents: Keep Each Customer's Data Apart
  52. 52What Is Agentic RAG? How It Differs from Classic RAG
  53. 53AI Agent Memory in Python: Short-Term and Long-Term
  54. 54Per-User Agent Memory Isolation: Stop Leaks Between Users
  55. 55Agentic RAG in Python: Give Your AI Agent a Search Tool
  56. 56AI Agent Reasoning Patterns in Python: From ReAct to Debate
  57. 57Plan-and-Execute Agents in Python: Beyond the ReAct Loop
  58. 58Self-Modifying AI Agent in Python: Open Mode & Limits
  59. 59CrewAI Alternatives: 7 Options and How to Migrate (2026)
  60. 60Migrate from AutoGen: Agent Framework, AG2 and More
  61. 61What Is an LLM Guardrail? Types, Examples and Limits
  62. 62Best LLM Guardrails Tools (2026): 9 Platforms Compared
  63. 63AI Agent Guardrails in Python: Block Injection, Redact PII
  64. 64NeMo Guardrails vs Guardrails AI: Which to Choose (2026)
  65. 65AI-Based PII Detection and Redaction Tools for LLM Apps
  66. 66Stop Secrets Leaking Into LLM Logs and Traces
  67. 67AI Agent Code Execution Sandbox: Run LLM Code Safely
  68. 68AI Agent Network Egress: Limit Where Agents Can Connect
  69. 69AutoGen Docker Task Isolation: Secure the Code Executor
  70. 70SPIFFE for AI Agents: Workload Identity Without API Keys
  71. 71On-Behalf-Of Auth for AI Agents: Act as Each User
  72. 72AI Agent Production Checklist: What to Check Before Launch
  73. 73Approval Fatigue: Auto-Approve Safe AI Agent Actions
  74. 74What Is Human in the Loop AI? Approvals for AI Agents
  75. 75AI Agent Notifications: Webhook and Slack Alerts in Python
  76. 76AI Agent Observability: Trace Tool Calls, Tokens and Cost
  77. 77Best AI Agent Observability Tools (2026), Compared
  78. 78AI Agent Stuck in a Loop? How to Detect and Stop It
  79. 79How to Run, Debug and Deploy an AI Agent in Python
  80. 80AI Agent Cost Tracking: Tokens and Cost per Run and User
  81. 81How to Evaluate AI Agents: Evals, LLM Judges and pass^k
  82. 82AI Agent Cost Control: Budgets That Stop Runaway Spend
  83. 83How to Test LLM Prompts and AI Agents in Python
  84. 84AI Agent Evals in CI: Run Them on Every Pull Request
  85. 85What Is an Agentic Runtime? AI Agent Runtimes Explained
  86. 86Autonomous AI Agent Runtime: Budgets, Crash Recovery, API
  87. 87Event-Driven AI Agents: Webhook, Cron and File Triggers
  88. 88AI Agent Cron Jobs: Run an Agent on a Schedule
  89. 89AI Agent Webhook Trigger: Run an Agent on HTTP Events
  90. 90AI Agent File Watcher: Process New Files Automatically
  91. 91Custom AI Agent Triggers: Wake an Agent From Any Source
  92. 92AI Agent Event Filters: Skip Runs Before the LLM
  93. 93AI Agent Retries and a Dead Letter Queue for Failed Runs
  94. 94Run Multiple AI Agents: One Runtime, Many Processes
  95. 95AI Agent Manifest: Declare a Long-Running Agent in YAML
  96. 96AI Agent CLI: Start, Stop and Inspect Running Agents
  97. 97AI Agent Monitoring Dashboard in the Terminal
  98. 98Multi-Agent Event Bus: Chain Agents With Events
  99. 99Distributed AI Agents: Run Agents Across Many Machines
  100. 100Pause and Resume an AI Agent: Lifecycle States Explained

Lessons in this path

  1. ✓What Is an AI Agent? Definition, How It Works, Examples
  2. ✓How to Build an AI Agent in Python (2026 Guide)
  3. ✓Build a Personal AI Agent: Memory, Reminders, Chat
  4. ✓What Is an Agent Harness? Parts and How to Build One
  5. ✓System Prompt Best Practices for AI Agents in Python
  6. ✓Best LLM for AI Agents (2026): Picks, Prices, How to Test
  7. ✓AI Agent YAML: Define and Run an Agent From a Config File
  8. ✓Streaming LLM Responses with FastAPI: Tokens and Tool Calls
  9. ✓Best Local LLM for AI Agents: Ollama Models by GPU (2026)
  10. ✓Claude AI Agent with MCP: Use Anthropic Models in Promptise
  11. ✓Gemini AI Agent with MCP: Use Google Models in Promptise
  12. 12Azure OpenAI Agent with MCP: Use Deployments in Promptise
  13. 13OpenRouter AI Agent with MCP: Many Models in Promptise
  14. 14Ollama AI Agent with MCP: Run Local Models in Promptise
  15. 15LLM Semantic Cache and Model Fallback in Python
  16. 16What Is MCP (Model Context Protocol)? A Developer's Guide
  17. 17What Is Tool Calling? LLM Function Calling Explained
  18. 18MCP Tools vs Resources vs Prompts (With Python Examples)
  19. 19How to Connect MCP Servers to Your AI Agent in Python
  20. 20Build a Production MCP Server in Python (Step by Step)
  21. 21MCP Transports: stdio vs Streamable HTTP vs SSE (Python)
  22. 22MCP 2026-07-28 Migration: Make Your MCP Server Stateless
  23. 23OpenAPI to MCP: Turn Any REST API into an MCP Server
  24. 24MCP Authentication in Python: API Keys, JWT and OAuth
  25. 25Build an Authenticated MCP Server for Your AI Agent (Python)
  26. 26MCP Security Best Practices: A Checklist for MCP Servers
  27. 27Testing MCP Servers in Python: pytest Without a Live Server
  28. 28Too Many MCP Tools? How to Fix LLM Tool Selection in Python
  29. 29Idempotent Tool Calls: Make AI Agent Retries Safe
  30. 30AI Agent Tool Failures: Stop Unsafe Workarounds
  31. 31MCP Server Caching, Timeouts and Circuit Breakers in Python
  32. 32MCP Middleware for Servers: Auth, Logging, Rate Limits
  33. 33MCP vs CLI for AI Agents: Tokens, Security, When to Use Each
  34. 34LangChain vs MCP: Differences and How They Work Together
  35. 35FastMCP Alternatives for Production MCP Servers (2026)
  36. 36AI Agent Audit Logging: Tamper-Evident Logs in Python
  37. 37AI Agent Human in the Loop: Approve Tool Calls in Python
  38. 38AI Agent Prompt Injection: How to Defend Against It
  39. 39Hidden Text Prompt Injection: Sanitize Pages for AI Agents
  40. 40Build a Multi-Agent System in Python (and When Not To)
  41. 41Context Engineering for AI Agents: Context Window Management
  42. 42Context Compaction for AI Agents: Trim vs Summarize
  43. 43How to Deploy an AI Agent with Docker (2026 Guide)
  44. 44LLM Tool Rate Limiting: Per-Client Limits for MCP Servers
  45. 45MCP Long-Running Tasks: Background Jobs in Python
  46. 46MCP Server Monitoring: Prometheus, OpenTelemetry and Logs
  47. 47Best AI Agent Frameworks (2026): Python Options Compared
  48. 48Self-Improving AI Agent: Learn From Tool Failures in Python
  49. 49AI Agent Identity: Authenticate Agents to MCP Servers
  50. 50Code-Action Agents in Python: One Program vs 37 Tool Calls
  51. 51Multi-Tenant AI Agents: Keep Each Customer's Data Apart
  52. 52What Is Agentic RAG? How It Differs from Classic RAG
  53. 53AI Agent Memory in Python: Short-Term and Long-Term
  54. 54Per-User Agent Memory Isolation: Stop Leaks Between Users
  55. 55Agentic RAG in Python: Give Your AI Agent a Search Tool
  56. 56AI Agent Reasoning Patterns in Python: From ReAct to Debate
  57. 57Plan-and-Execute Agents in Python: Beyond the ReAct Loop
  58. 58Self-Modifying AI Agent in Python: Open Mode & Limits
  59. 59CrewAI Alternatives: 7 Options and How to Migrate (2026)
  60. 60Migrate from AutoGen: Agent Framework, AG2 and More
  61. 61What Is an LLM Guardrail? Types, Examples and Limits
  62. 62Best LLM Guardrails Tools (2026): 9 Platforms Compared
  63. 63AI Agent Guardrails in Python: Block Injection, Redact PII
  64. 64NeMo Guardrails vs Guardrails AI: Which to Choose (2026)
  65. 65AI-Based PII Detection and Redaction Tools for LLM Apps
  66. 66Stop Secrets Leaking Into LLM Logs and Traces
  67. 67AI Agent Code Execution Sandbox: Run LLM Code Safely
  68. 68AI Agent Network Egress: Limit Where Agents Can Connect
  69. 69AutoGen Docker Task Isolation: Secure the Code Executor
  70. 70SPIFFE for AI Agents: Workload Identity Without API Keys
  71. 71On-Behalf-Of Auth for AI Agents: Act as Each User
  72. 72AI Agent Production Checklist: What to Check Before Launch
  73. 73Approval Fatigue: Auto-Approve Safe AI Agent Actions
  74. 74What Is Human in the Loop AI? Approvals for AI Agents
  75. 75AI Agent Notifications: Webhook and Slack Alerts in Python
  76. 76AI Agent Observability: Trace Tool Calls, Tokens and Cost
  77. 77Best AI Agent Observability Tools (2026), Compared
  78. 78AI Agent Stuck in a Loop? How to Detect and Stop It
  79. 79How to Run, Debug and Deploy an AI Agent in Python
  80. 80AI Agent Cost Tracking: Tokens and Cost per Run and User
  81. 81How to Evaluate AI Agents: Evals, LLM Judges and pass^k
  82. 82AI Agent Cost Control: Budgets That Stop Runaway Spend
  83. 83How to Test LLM Prompts and AI Agents in Python
  84. 84AI Agent Evals in CI: Run Them on Every Pull Request
  85. 85What Is an Agentic Runtime? AI Agent Runtimes Explained
  86. 86Autonomous AI Agent Runtime: Budgets, Crash Recovery, API
  87. 87Event-Driven AI Agents: Webhook, Cron and File Triggers
  88. 88AI Agent Cron Jobs: Run an Agent on a Schedule
  89. 89AI Agent Webhook Trigger: Run an Agent on HTTP Events
  90. 90AI Agent File Watcher: Process New Files Automatically
  91. 91Custom AI Agent Triggers: Wake an Agent From Any Source
  92. 92AI Agent Event Filters: Skip Runs Before the LLM
  93. 93AI Agent Retries and a Dead Letter Queue for Failed Runs
  94. 94Run Multiple AI Agents: One Runtime, Many Processes
  95. 95AI Agent Manifest: Declare a Long-Running Agent in YAML
  96. 96AI Agent CLI: Start, Stop and Inspect Running Agents
  97. 97AI Agent Monitoring Dashboard in the Terminal
  98. 98Multi-Agent Event Bus: Chain Agents With Events
  99. 99Distributed AI Agents: Run Agents Across Many Machines
  100. 100Pause and Resume an AI Agent: Lifecycle States Explained
← Path overview

This guide shows how to build an Azure OpenAI agent with MCP tools: an agent that runs on OpenAI models deployed in your own Azure resource and calls tools from a Model Context Protocol server. It is for developers whose company runs models through Azure AI Foundry for data residency, private networking or billing, and who need the Azure-specific settings right. You will learn the four values Azure needs, the two API styles, keyless sign-in with Entra ID, and the errors you are most likely to hit.

[01]

How do you use Azure OpenAI with Promptise?

Deploy a model in Azure AI Foundry, then pass Model("gpt-5-mini", provider="azure", deployment="<your deployment name>") to build_agent(), with the endpoint, key and API version in AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_KEY and OPENAI_API_VERSION. Promptise builds LangChain's AzureChatOpenAI, which is part of the core install. Add your MCP servers in servers=, and the agent sends their tools to your deployment as function definitions and runs the calls the model makes.

  • Azure routes by deployment name, not model name. The deployment is what you called the model when you deployed it. Getting this wrong is the most common Azure error.

  • Four values identify a deployment: the model, the deployment name, the resource endpoint and the API version, plus a key or an Entra ID identity.

  • Azure's v1 API needs no API version. You can reach it through Promptise's openai provider with endpoint=.

  • Entra ID works without a key. Pass a token provider from azure-identity.

  • Check before you call. promptise models check azure:<deployment> names every missing value and where to find it in the portal.


[02]

Set up Azure OpenAI

You need Python 3.10 or later, Promptise Foundry 1.11.0 or later, an Azure subscription and a resource with a deployed model. In the Azure AI Foundry portal, deploy a model (this guide uses gpt-5-mini) and give the deployment a name. The examples call it shop-agent.

>_Terminal
pip install "promptise>=1.11.0"

Collect four values from the portal:

You need

Where it is

Promptise word

Variable

The model (gpt-5-mini)

Deployments, the Model column

model

none

The deployment name (shop-agent)

Deployments, the Name column

deployment

none (or the string form)

The endpoint

Your resource, Overview, Endpoint (https://<resource>.openai.azure.com/, no path)

endpoint

AZURE_OPENAI_ENDPOINT

A key

Your resource, Keys and Endpoint, KEY 1

api_key

AZURE_OPENAI_API_KEY

The API version

Azure's API version lifecycle page

api_version

OPENAI_API_VERSION

promptise models env azure prints the lines for your .env file, with a note on where each value is:

Output
# Azure OpenAI (OpenAI models deployed in Azure AI Foundry) — model string example: azure:chat-prod
export AZURE_OPENAI_ENDPOINT=https://my-resource.openai.azure.com/
#   ↳ Azure AI Foundry portal → your resource → Overview → Endpoint (https://<resource>.openai.azure.com/, no path)
export AZURE_OPENAI_API_KEY=...
#   ↳ Azure AI Foundry portal → your resource → Keys and Endpoint → KEY 1 (or Entra ID: pass extra={'azure_ad_token_provider': ...})
export OPENAI_API_VERSION=2024-10-21
#   ↳ the REST API version your deployment supports, e.g. 2024-10-21 (Azure docs → 'API version lifecycle')

Promptise loads the nearest .env file automatically, and variables already exported in your shell win. Pick an API version that supports the model you deployed. Reasoning parameters such as reasoning_effort arrived in 2024-12-01-preview, so for a GPT-5 model use a later version such as 2025-04-01-preview, or skip versions entirely with the v1 API described below.

With nothing set, the check lists every value and where to get it:

Output
$ promptise models check azure:shop-agent
azure:shop-agent → azure_openai:shop-agent  (Azure OpenAI (OpenAI models deployed in Azure AI Foundry))
  model part: shop-agent — in the string form, your DEPLOYMENT name (Foundry → Deployments → Name); with Model(...), the model name (gpt-4o); the deployment goes in deployment=
  route: native integration (core)
  AZURE_OPENAI_ENDPOINT: MISSING — Azure AI Foundry portal → your resource → Overview → Endpoint (https://<resource>.openai.azure.com/, no path)
  AZURE_OPENAI_API_KEY: MISSING — Azure AI Foundry portal → your resource → Keys and Endpoint → KEY 1 (or Entra ID: pass extra={'azure_ad_token_provider': ...})
  OPENAI_API_VERSION: MISSING — the REST API version your deployment supports, e.g. 2024-10-21 (Azure docs → 'API version lifecycle')
  Azure routes requests by deployment name, not model name: Model('gpt-4o', provider='azure', deployment='chat-prod', ...).
Not usable yet.
  - AZURE_OPENAI_ENDPOINT is not set: Azure AI Foundry portal → your resource → Overview → Endpoint (https://<resource>.openai.azure.com/, no path) (e.g. https://my-resource.openai.azure.com/)
  - AZURE_OPENAI_API_KEY is not set: Azure AI Foundry portal → your resource → Keys and Endpoint → KEY 1 (or Entra ID: pass extra={'azure_ad_token_provider': ...})
  - OPENAI_API_VERSION is not set: the REST API version your deployment supports, e.g. 2024-10-21 (Azure docs → 'API version lifecycle') (e.g. 2024-10-21)
  - put AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_KEY, OPENAI_API_VERSION in a .env file next to your script (loaded automatically; a variable already exported with a non-empty value wins, an empty one is filled from the file), export it, or pass it in code: Model(..., endpoint=, api_key=, api_version=). See promptise models env azure

With the three variables set, it reports the route and stops before calling anything:

Output
$ promptise models check azure:shop-agent
azure:shop-agent → azure_openai:shop-agent  (Azure OpenAI (OpenAI models deployed in Azure AI Foundry))
  model part: shop-agent — in the string form, your DEPLOYMENT name (Foundry → Deployments → Name); with Model(...), the model name (gpt-4o); the deployment goes in deployment=
  route: native integration (core)
  AZURE_OPENAI_ENDPOINT: set — Azure AI Foundry portal → your resource → Overview → Endpoint (https://<resource>.openai.azure.com/, no path)
  AZURE_OPENAI_API_KEY: set — Azure AI Foundry portal → your resource → Keys and Endpoint → KEY 1 (or Entra ID: pass extra={'azure_ad_token_provider': ...})
  OPENAI_API_VERSION: set — the REST API version your deployment supports, e.g. 2024-10-21 (Azure docs → 'API version lifecycle')
  Azure routes requests by deployment name, not model name: Model('gpt-4o', provider='azure', deployment='chat-prod', ...).
Configuration OK — every required setting is in place; nothing was called. Add --ping to make a real one-token call to the model.

The check proves the configuration is complete. --ping makes one real call, which also proves the deployment name and key are right.


[03]

Build a minimal Azure agent

The agent answers questions about a shop's products. The model is configured once at the top of the file:

Pythonazure_agent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import asyncio
import sys

from promptise import Model, build_agent
from promptise.config import StdioServerSpec

# Endpoint, key and API version come from AZURE_OPENAI_ENDPOINT,
# AZURE_OPENAI_API_KEY and OPENAI_API_VERSION (environment or .env).
AZURE = Model("gpt-5-mini", provider="azure", deployment="shop-agent")


async def make_agent(model=AZURE):
    return await build_agent(
        model=model,
        servers={"shop": StdioServerSpec(command=sys.executable, args=["shop_server.py"])},
        instructions="You answer questions about the shop's products. "
                     "Use the tools for stock and prices. Never guess them.",
        max_agent_iterations=10,
    )


async def main():
    agent = await make_agent()
    try:
        result = await agent.ainvoke(
            {"messages": [{"role": "user", "content": "Is KB-101 in stock, and what does it cost?"}]}
        )
        calls = [c["name"] for m in result["messages"] for c in getattr(m, "tool_calls", None) or []]
        print("tool calls:", ", ".join(calls) or "none")
        print(result["messages"][-1].text)
    finally:
        await agent.shutdown()


if __name__ == "__main__":
    asyncio.run(main())

What each part does:

  • Model("gpt-5-mini", provider="azure", deployment="shop-agent"). The first argument is the model, which LangChain uses for token accounting. Requests go to the deployment: /openai/deployments/shop-agent/chat/completions on your endpoint. If you leave deployment out, it defaults to the model name, which is only right if you named the deployment after the model.

  • The string form is "azure:shop-agent", where the part after the colon is the deployment name. Use it when everything else is in the environment.

  • max_agent_iterations=10 stops a run that keeps calling tools without finishing.

  • result["messages"][-1].text reads the answer text.

To keep credentials in code instead, for example when they come from a secret store, pass them as words:

Python
1
2
3
4
5
6
7
8
AZURE = Model(
    "gpt-5-mini",
    provider="azure",
    deployment="shop-agent",
    endpoint="https://my-resource.openai.azure.com/",
    api_key=secrets["azure-openai-key"],
    api_version="2025-04-01-preview",
)

A value given in code counts as provided, so the matching variable isn't needed. A blank string doesn't count, so an empty ${AZURE_OPENAI_API_KEY} in a config file falls back to the environment instead of sending an empty key.

Run it with python azure_agent.py. With a valid deployment, the script prints the tools the model called and then its answer.


[04]

Use MCP tools with Azure OpenAI

The tools come from a small MCP server the agent starts over stdio:

Pythonshop_server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""A small MCP tool server: product stock and prices for a shop."""
from promptise.mcp.server import MCPServer

server = MCPServer("shop")

STOCK = {"KB-101": 14, "MS-220": 0, "HD-350": 3}
PRICES = {"KB-101": 89.00, "MS-220": 39.50, "HD-350": 129.00}


@server.tool()
async def check_stock(sku: str) -> dict:
    """How many units of a product (by SKU) are in stock."""
    if sku not in STOCK:
        return {"sku": sku, "error": "unknown SKU"}
    return {"sku": sku, "in_stock": STOCK[sku]}


@server.tool()
async def get_price(sku: str) -> dict:
    """The current price of a product (by SKU), in USD."""
    if sku not in PRICES:
        return {"sku": sku, "error": "unknown SKU"}
    return {"sku": sku, "price_usd": PRICES[sku]}


if __name__ == "__main__":
    server.run()  # stdio by default
Your code calls the Promptise agent, which calls the Azure OpenAI deployment over HTTPS and runs the returned tool_calls on shop_server.py over stdio as the MCP client. The tool result goes into the next model call, and the MCP server never talks to Azure.
FigureThe Promptise agent calls the Azure OpenAI deployment and runs its tool calls on the MCP server

Promptise is the MCP client. It connects to each server in servers=, lists the tools and sends them to the deployment as function definitions on every call. When the model returns tool calls, Promptise runs them against the MCP server and calls the model again with the results. The MCP server never talks to Azure, so it can stay on a private network next to the agent. To connect a remote MCP server, use HTTPServerSpec(url=..., bearer_token=...) from promptise.config. The MCP connection guide covers the options.


[05]

Azure-specific notes

The v1 API: no API version

Azure's v1 API accepts the standard OpenAI client at https://<resource>.openai.azure.com/openai/v1/ and needs no api-version. In Promptise, that is the openai provider with your Azure endpoint. The model is the deployment name:

Python
1
2
3
4
5
6
AZURE_V1 = Model(
    "shop-agent",
    provider="openai",
    endpoint="https://my-resource.openai.azure.com/openai/v1/",
    api_key=secrets["azure-openai-key"],
)

Use this route when you don't want to track API versions. The classic provider="azure" route remains the one promptise models check explains field by field.

Keyless sign-in with Entra ID

Some organizations disable key authentication on their Azure OpenAI resources. With Entra ID, pass a token provider from azure-identity, which you install yourself (pip install azure-identity). Since 1.11.0, a token provider (or a token in extra={"azure_ad_token": ...}) counts as the credential, so AZURE_OPENAI_API_KEY isn't needed. Older versions asked for a key even then.

Python
1
2
3
4
5
6
7
8
9
10
11
12
13
from azure.identity import DefaultAzureCredential, get_bearer_token_provider

token = get_bearer_token_provider(
    DefaultAzureCredential(), "https://ai.azure.com/.default"
)
AZURE = Model(
    "gpt-5-mini",
    provider="azure",
    deployment="shop-agent",
    endpoint="https://my-resource.openai.azure.com/",
    api_version="2025-04-01-preview",
    extra={"azure_ad_token_provider": token},
)

The identity running the agent (your az login account locally, a managed identity in Azure) needs the Cognitive Services OpenAI User role on the resource. Tokens are refreshed for you. Microsoft's managed identity guide covers role assignment.

Reasoning models and tools

GPT-5 and o-series models are reasoning models. They reject temperature, top_p and the old max_tokens field, so leave temperature out of Model(...). max_tokens= in Model(...) is safe, because LangChain sends it as max_completion_tokens. To set reasoning depth, pass extra={"reasoning_effort": "low"}.

Promptise calls Azure through the Chat Completions API. Microsoft's reasoning models page notes that some newer models, such as the gpt-5.6 family, can't combine reasoning and function tools on Chat Completions and return an error when tools are sent. For those deployments, either set extra={"reasoning_effort": "none"} or deploy a model that supports tools with reasoning on Chat Completions. Check the page for the model you plan to use.

Quotas, content filters and pricing

Each deployment has a tokens-per-minute quota, and requests beyond it get HTTP 429. Agents send several model calls per question, so size the quota for that. See quotas and limits. Azure also runs content filters on prompts and completions, so a blocked request fails with a content filter error rather than an answer. Prices depend on the model, region and deployment type. See the Azure OpenAI pricing page, and put a budget on the agent.

Other models in Azure AI Foundry

Llama, Mistral, DeepSeek and the rest of the Foundry catalog use a different endpoint (https://<resource>.services.ai.azure.com/models) and key. In Promptise that is provider="foundry" with AZURE_INFERENCE_ENDPOINT and AZURE_INFERENCE_CREDENTIAL. The models reference has the details.


[06]

Common problems and fixes

Symptom

Cause

Fix

AZURE_OPENAI_ENDPOINT is not set (or the key or API version)

A value is missing from the environment and the code

Set it in .env, export it, or pass endpoint=, api_key=, api_version=

HTTP 404 DeploymentNotFound

The deployment isn't the Name column in Deployments, or the endpoint belongs to another resource

Copy the Name, not the Model, and check the endpoint

HTTP 401, access denied

Wrong key, or a key from another resource

Copy KEY 1 from the same resource as the endpoint

HTTP 401 or 403 with Entra ID

The identity lacks the role, or the token scope is wrong

Assign Cognitive Services OpenAI User, and use the https://ai.azure.com/.default scope from Microsoft's current docs

HTTP 400 about the API version or an unsupported parameter

The API version is too old for the model or the parameter

Use a newer version from the lifecycle page, or the v1 API

HTTP 400 saying temperature is an unsupported parameter

temperature set for a reasoning model

Remove it, and use reasoning_effort instead

Function tools with reasoning_effort are not supported

A model that can't combine tools and reasoning on Chat Completions

Set reasoning_effort to none, or use another model

HTTP 429

The deployment's tokens-per-minute quota

Raise the quota, lower concurrency, or add a FallbackChain to a second deployment

OpenAIConnectionError: Connection error.

The endpoint host doesn't exist or isn't reachable (private endpoint, firewall, typo)

Check the endpoint and that the agent runs inside the allowed network

The last row is the real error the example printed with an endpoint that doesn't exist. The other rows are described from Azure's and Promptise's documentation, not from a recorded run.


[07]

Frequently asked questions

What is the difference between the model name and the deployment name in Azure OpenAI?

The model is what you deployed, such as gpt-5-mini. The deployment name is the label you chose when you deployed it, such as shop-agent, and it's what Azure uses to route each request. In Promptise, put the model in the first argument of Model(...) and the deployment in deployment=. In the string form "azure:shop-agent", the part after the colon is the deployment name.

Which API version should I use for an Azure OpenAI agent?

Use one that supports your model and the features you need, listed on Azure's API version lifecycle page. For GPT-5 models with reasoning settings, use 2024-12-01-preview or later. If you'd rather not track versions, use the v1 API at https://<resource>.openai.azure.com/openai/v1/ through Promptise's openai provider. It needs no version.

Can I use Azure OpenAI without API keys?

Yes. Pass a token provider from azure-identity in extra={"azure_ad_token_provider": ...} and leave out api_key. Since 1.11.0 the token counts as the credential, so no AZURE_OPENAI_API_KEY is needed. DefaultAzureCredential uses your az login account locally and a managed identity in Azure. The identity needs the Cognitive Services OpenAI User role on the resource.

Do MCP tools work with Azure OpenAI's data and network restrictions?

Yes. Promptise runs the MCP client in your process, so the MCP servers only need to be reachable from the agent, not from Azure. Azure only sees the tool definitions and the tool results in the conversation. If tool results contain sensitive data, they're sent to your deployment like any other prompt content, under your Azure data terms.

Can I switch an Azure agent to OpenAI or another provider?

Yes. Change the Model(...) line, for example to "openai:gpt-5-mini" or a Claude model, and keep the rest of the agent. The instructions and MCP servers don't change. Rerun your tests after the switch, because the same model on Azure and on OpenAI can still differ in version and content filtering.


[08]

Next steps

  • Build the full agent step by step: how to build an AI agent.

  • Compare models before you deploy one: best LLM for AI agents.

  • Serve several customers from one agent: multi-tenant AI agent.

  • Run it in production: deploy AI agents in production.

  • Write the tool side: build a production MCP server.

  • Every Azure word in one place: Models and providers reference.

← PreviousGemini AI Agent with MCP: Use Google Models in PromptiseNext lesson →OpenRouter AI Agent with MCP: Many Models in Promptise