Skip to content

Azure-Samples/serverless-agents-expense-processor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serverless Expense Processor Agent Python

A markdown-first Azure Functions serverless agent for queue-driven expense processing. Its trigger and instructions live in src/agents/expense_processor.agent.md, and Azure Functions handles execution and scale-to-zero.

What it does

  • 🧾 Reads any format: text, email, key/value, or JSON, and extracts amount, currency, category, and vendor.
  • 📚 Picks the right policy: lists the documents in Blob Storage and selects the one whose scope matches, then reads and applies it.
  • 🚦 Routes the decision: approveexpense-approved, reviewexpense-review, flag / FX → expense-flagged.
  • 🔀 Proves it's reasoning: the same $450 is auto-approved as travel but sent to review as a client dinner; tighten one policy document and only that category reroutes.

Prerequisites

Quickstart

azd up

Wait up to a minute, then read the decisions:

uv run scripts/read_decision.py --queue all --peek --cloud

You should see:

Request Policy Queue
$450 flight travel-policy.md expense-approved
$450 monitor equipment-software-policy.md expense-approved
$450 client dinner meals-entertainment-policy.md expense-review

Clean up with azd down --purge.

Run it locally (Azurite)

Install Azurite and Azure Functions Core Tools. Copy src/local.settings.json.sample to src/local.settings.json and set the model endpoint and deployment.

azurite --silent --location .azurite               # terminal A
cd src && uv run func start                         # terminal B
uv run scripts/send_expense.py --file samples/travel.txt   # terminal C
uv run scripts/read_decision.py --queue all --peek

The model call still uses Azure. For setup and Windows help, see Troubleshooting.

How it works

flowchart LR
    msg([raw message<br/>text · JSON · key-value])

    subgraph inbound["Azure Queue Storage · inbound"]
        inq[[expense-requests]]
    end

    subgraph policies["Azure Blob Storage · policies container"]
        pdocs[(travel · meals · equipment<br/>general policy docs)]
    end

    agent{{Expense Processor agent<br/>extract · select · apply · route}}

    subgraph outbound["Azure Queue Storage · outbound"]
        approved[[expense-approved]]
        review[[expense-review]]
        flagged[[expense-flagged]]
    end

    msg --> inq
    inq -->|queue trigger| agent
    pdocs --> agent
    agent --> approved
    agent --> review
    agent --> flagged
Loading

The runtime discovers the agent Markdown file. Its front matter defines the queue trigger, and its body contains the instructions. Three Python tools read policy documents and route decisions using managed identity.

How it works · Use cases · Customize · Deploy · Troubleshooting

Learn more

License

MIT © Microsoft Corporation.

About

Queue-triggered AI agent on Azure Functions that reads an expense request in any format, applies a spending policy, and routes it to approve/review/flag queues.

Resources

License

Code of conduct

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors