Automating Procurement Audits Using Agentic AI Workflows and Code Interpreter in Azure Logic App
The recent introduction of the Code Interpreters inside Microsoft Azure logic app allows makers to generate and execute JavaScript code directly within prompts. This enables advanced analysis, visualizations, validations and transformations. Presently, code interpreter supports JavaScript but other languages will follow in future.
By executing data analysis, calculations, and transformations independently of the model’s context window, code interpreters avoid context overflow and reduce hallucination risks. This separation allows the model to deliver more accurate and trustworthy results.
In this blog, we’ll explore how to harness the Code Interpreter in azure logic app to automate a real world audit scenario.
Prerequisites
- You need azure subscription with access to azure portal
- You need appropriate permissions to create logic app resource in azure portal.
*** For Logic Apps Consumption as the service runs in a multi‑tenant environment, so an Integration Account is required to isolate code interpreter workloads. This ensures the interpreter runs on dedicated compute instead of shared resources.
You can create an Integration Account from the Azure portal (the Free SKU works for non‑production). After provisioning, attach it to your Consumption Logic App under Settings → Integration Account

Scenario
Automating Procurement Audits
An enterprise receives:
- An csv file with procurement transactions
- High-risk vendors flagged in a compliance audit are stored in another csv file
The goal is to automate the audit process to flag transactions over $10,000 with missing PO numbers or involving high-risk vendors.
Solution
Step 1: Create a logic app, for this demo I am using “Consumption” hosting plan
Enter Subscription, resource group, logic app name, region. Choose workflow type as “Autonomous Agents (Preview)”

Click “Review + Create” to create a logic app.
Step 2: Once logic app is deployed. Go to resource and navigate to logic app designer from left navigation

Step 3: Design the autonomous agent workflow
Firstly, add a trigger by selecting “When a HTTP request is received” from the right panel. This will set the trigger point for this workflow

Next, add schema JSON for the http trigger by adding below code in the request body schema JSON parameter:
{
"type": "object",
"properties": {
"procurementcsvdata": {
"type": "string"
},
"highriskvendorcsv": {
"type": "string"
}
}
}

Post that, add “AI Agent” action. The flow will like this

Rename the agent name to “Procurement Audit Agent” and enter the below text in the instructions box:
# Procurement Audit agent - system prompt
You are a procurement audit agent that process financial transactions.
Follow the below steps in the following order:
## Step 1: Get Business Rules
Read all business rules from Tool_GetBusinessRule.
##Step 2: Get High Risk Vendors list
Read high risk vendor list from Tool_GetHighRiskVendors.
## Step 3: Parse all csv transactions in user prompt using code interpreter and cross reference and flag risky transactions. Return flagged rows in csv with comments.
DONOT return any error in the final output csv data.

To pass the csv data from trigger to agent, we will use fx expression. In the user instruction item 1 parameter, enter the below fx expression, just copy and paste below code directly in the item 1 textbox:
@{json(triggerBody())?['procurementcsvdata']}

Don’t forget to enable “Code Interpreter” in AI agent action:

Within AI Agent action, add a compose action. The compose action will automatically wrapped inside “Tool” action as shown below:

Rename the “Tool” action as ‘Tool_GetBusinessRule’ and enter the below text in its description:
Return the business rules to validate data

rename the compose action as “Compose – Business Rules” and enter below business rules in the inputs textbox:
- Identify transactions over $10,000 with missing PO numbers.
- Cross-reference and flag risky transactions.

Similarly, add another compose action inside “AI Agent” action. Reanme the tool action to ‘Tool_GetHighRiskVendors’ & enter the below description for the tool:
Read high risk vendors to validate transactions data

Rename the compose action inside “Tool_GetHighRiskVendors” action to ‘Compose – High Risk Vendors’. Enter the below fx expression in its inputs textbox:
@{json(triggerBody())?['highriskvendorcsv']}
*just copy & paste above expression code directly into the inputs textbox

To get the output message from the “AI Agent” action, add a compose action outside “AI Agent” action. rename the compose action to “Compose – output csv data”. Dynamically pass the output of AI agent action (last assistant message) to the input of compose action:

Finally, we will add response action to return the http endpoint response to the caller. Pass the output of last compose action in the response body of this action:

The flow structure will look like this once it is completed:

Run flow
In the new designer, we can run the flow in draft state using “Run draft” option. Click “Run draft” button on the bottom and provide the below payload in the input body:
{
"procurementcsvdata": "Transaction ID,Vendor Name,Invoice Amount,PO Number,Transaction Date\nTXN10000,Vendor 1,$15900.79,PO-2000,2025-08-25\nTXN10001,Vendor 2,$26701.31,,2025-09-01\nTXN10002,Vendor 3,$22160.53,PO-2002,2025-07-11\nTXN10003,Vendor 4,$15270.02,PO-2003,2025-07-10\nTXN10004,Vendor 5,$30980.08,PO-2004,2025-07-19\nTXN10005,Vendor 6,$7830.52,PO-2005,2025-08-18\nTXN10006,Vendor 7,$15310.51,PO-2006,2025-08-30\nTXN10007,Vendor 8,$18950.17,PO-2007,2025-07-26\nTXN10008,Vendor 9,$23304.74,PO-2008,2025-08-10\nTXN10009,Vendor 10,$30947.36,PO-2009,2025-08-28\nTXN10010,Vendor 11,$10078.40,PO-2010,2025-08-06\nTXN10011,Vendor 12,$26190.75,,2025-09-02\nTXN10012,Vendor 13,$30020.83,PO-2012,2025-07-13\nTXN10013,Vendor 14,$3027.61,PO-2013,2025-08-20\nTXN10014,Vendor 15,$30706.97,PO-2014,2025-07-27\nTXN10015,Vendor 16,$30706.97,PO-2015,2025-07-28\nTXN10016,Vendor 17,$30706.97,PO-2016,2025-07-29\nTXN10017,Vendor 18,$30706.97,PO-2017,2025-07-30\nTXN10018,Vendor 19,$30706.97,PO-2018,2025-07-31",
"highriskvendorcsv": "Vendor 1,Vendor 5"
}

Click “Run draft with payload” button to run the flow.
The agent took 6 iterations to complete the auditing process:

As per the steps mentioned in the “AI Agent” action, it first reads the business rules and high risk vendors. In 3rd & 4th iterations, it executes JavaScript code to perform auditing operation on the input csv data:

Finally, it returns the flagged tractions with comments at the last column:

Output
The output csv containing flagged invoice transactions will look like:

Conclusion
- The Code Interpreter unlocks a new dimension in azure logic app workflow automation.
- Code interpreters execute data analysis, calculations, validations and transformations outside the model’s context window, preventing overflow.
- This separation reduces hallucination risks and enables more accurate, trustworthy results.
- Pre-processing data before the model reduces token consumption, cutting costs and latency.
- Integrating Code Interpreter into Logic App workflows is a competitive advantage for building reliable, scalable enterprise solutions.