Invoicing · 15 / 26

Microsoft Foundry Example

The receivables platform's dispute agent built on Microsoft Foundry: agent service, Azure AI (artificial intelligence) Search, Entra ID (identifier), tracing and evaluation.

The same platform on Microsoft Foundry

Microsoft Foundry (formerly Azure AI Foundry) is Microsoft's platform for building and running AI applications and agents. This build keeps the contracts from the overall design and maps each part onto a Foundry or Azure service. It suits teams already standardised on Azure and Entra ID.

Design partIn Microsoft Foundry
Orchestrator and agentsFoundry agents in a project, with instructions and tools. A thin service in front handles batch intake and the pipeline
ModelsModel deployments in the project, reached through the enterprise AI gateway for scanning and budgets
Clause indexAzure AI Search index (now presented as Foundry IQ) with a knowledge tool on the agent, filtered by customer and date
Tool gatewayThe receivables API (Application Programming Interface) as an OpenAPI tool, or the MCP (Model Context Protocol) gateway attached as an MCP tool
IdentityMicrosoft Entra ID, managed identities and role-based access control; no keys in code
SafetyFoundry content filters and guardrails, in addition to Prisma AIRS at the gateway
Tracing and evaluationOpenTelemetry traces to Application Insights, and Foundry evaluators for agents

Build steps

  1. 1 · Create the project

    One Foundry project per environment, with a managed identity and role assignments for search, storage and the receivables API.

  2. 2 · Deploy models

    Deploy the small and reasoning models and point the project at the enterprise gateway so every call is scanned and budgeted.

  3. 3 · Build the clause index

    Load contracts into Azure AI Search with customer and effective-date fields, and attach it as the agent's knowledge tool.

  4. 4 · Register tools

    Describe the evidence, proposal and approval-gated operations as an OpenAPI tool. Credit and message operations require an approval token issued by the review desk.

  5. 5 · Create the agents

    Write instructions, attach tools and run a thread per dispute or collections case.

  6. 6 · Trace and evaluate

    Turn on tracing, run agent evaluators on the shared evaluation set and gate releases on the result.

Creating the agent

A sketch with the Azure AI Projects SDK (Software Development Kit). The SDK changes quickly, so confirm the current class and method names. The important points are the identity, the tool set and the thread per case.

foundry/dispute_agent.py · a sketch, not a pinned SDK version
from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient

project = AIProjectClient(
    endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
    credential=DefaultAzureCredential(),            # managed identity in Azure, your login locally
)

agent = project.agents.create_agent(
    model="ar-reasoner",                            # deployment name, routed through the gateway
    name="dispute-agent",
    instructions=open("prompts/dispute_agent.md").read(),
    tools=[SEARCH_CLAUSES_TOOL, RECEIVABLES_OPENAPI_TOOL],   # clauses from AI Search, evidence via OpenAPI
)

def investigate(thread_id: str | None, case_summary: str):
    thread = project.agents.threads.get(thread_id) if thread_id else project.agents.threads.create()
    project.agents.messages.create(thread_id=thread.id, role="user", content=case_summary)
    run = project.agents.runs.create_and_process(thread_id=thread.id, agent_id=agent.id)
    return thread.id, run
A Foundry agent run for a dispute The service adds the case summary to a thread and runs the dispute agent. The agent calls the model through the gateway, reads the evidence through the OpenAPI tool, searches clauses and returns a draft. A collector approves the dispute, and the credit manager approves the credit through a separate approval token. Intake service Foundry agent Model via gateway AI Search Receivables API Credit manager case summary, run thread plan the case call get_dispute_evidence OpenAPI: evidence order, delivery, claims query clauses, customer filter clause 9.2 draft from evidence and clause draft draft for approval credit recommendation approval token run with token in context create_credit_note + key + token CN-3391
A Foundry agent run for a dispute

The agent proposes and drafts. The service controls when an approval token exists, so the agent cannot credit on its own initiative.

Keeping money movements safe

Evaluation in Foundry

What is measuredEvaluatorThreshold
Did the agent understand the disputeIntent resolutionAt least 0.9 on the set
Did it call the right tool with the right argumentsTool call accuracyAt least 0.95
Did it follow its instructions and policiesTask adherenceAt least 0.95
Are clause statements supported by the sourcesGroundednessAt least 0.9
Is anything unsafe or leakedSafety evaluators and a custom checkZero failures

Thresholds are illustrative. Set them from your own baseline and review them as the set grows.

When to choose it

Choose Foundry whenChoose another build when
The organisation standardises on Azure, Entra ID and Application InsightsYou need to control the graph and its checkpoints in code
Managed hosting of agent threads and tools is a benefitYou need to run the agents in a network where Foundry is not available
Security and operations teams already work in Azure toolsYour evaluation and tracing tools are built around another stack

Build this for your business

This example is a receivables platform for a distributor, but the same pattern, deterministic financial rules, a governed gateway, runtime security, grounded evidence and measured quality, fits any back-office process that moves money. We can scope a pilot on your own systems.

Book a discovery call