Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies only to:
Foundry (classic) portal. This article isn't available for the new Foundry portal. Learn more about the new portal.
Note
Links in this article might open content in the new Microsoft Foundry documentation instead of the Foundry (classic) documentation you're viewing now.
Note
The Assistants API is deprecated and will be retired on August 26, 2026. Use the generally available Microsoft Foundry Agents service. Follow the migration guide to update your workloads. Learn more.
To extend assistants in Foundry so they can work with your business or enterprise systems and automate real-world tasks, you can run workflows in Azure Logic Apps as assistant functions. These functions automate business tasks without requiring custom code. On their own, assistants can't directly manage data in customer databases, submit orders, send notifications, or trigger complex business processes when they need to do so.
Azure Logic Apps is an integration platform lets you build automated workflows by using a visual designer. Rather than writing custom backend code for each integration, you can create logic app workflows from 1,400+ connectors that access Azure, Microsoft, and non-Microsoft services, systems, apps, and data sources, such as SAP, Salesforce, and Oracle.
When you expose a logic app workflow as a callable function, your assistant chooses when to run the workflow based on chat conversation context and user prompts. With so many integration options, your assistant can work with nearly any business system or service your organization uses. This pattern provides a practical way to automate multistep tasks and integrate assistant conversations with your enterprise infrastructure. You don't need to build and maintain custom APIs for every business task that your assistant needs to perform. Azure Logic Apps handles authentication, retries, error handling, and monitoring, so you can focus on workflow logic rather than infrastructure.
This article shows how to create and set up a workflow in Azure Logic Apps as a tool for your assistant in Foundry Agent Service.
Prerequisites
An Azure account and subscription. Get a free Azure account.
-
This project organizes your work and saves the state while you build your AI apps and solutions.
A Consumption logic app resource and workflow that meets the following requirements:
Requirement Description Hosting option Uses the Consumption hosting option. Azure subscription Uses the same subscription as your Foundry project. Azure resource group Uses the same resource group as your Foundry project. Request trigger The operation that specifies the conditions to meet before running any subsequent actions in the workflow. The default trigger name is When an HTTP request is received.
Function calling requires a REST-based API. The Request trigger provides a REST endpoint that a service or system can call to run the workflow. So, for function calling, you can use only workflows that start with the Request trigger.Trigger description This description helps the AI assistant choose the appropriate function in Foundry. To enter this description, follow these steps in Create a logic app resource and workflow. Trigger schema A JSON schema that describes the expected inputs for the trigger. To enter or define this schema, follow these steps in Create a logic app resource and workflow.
Foundry automatically imports the schema as the function definition. For more information, see Request trigger.Response action The workflow must always end with this action, which returns the response to Foundry when the workflow completes. You can use logic app workflows that meet these requirements as functions that AI assistants can call in Foundry. To implement your business logic or use case, workflows can contain any other actions from the connectors gallery. For example, you can connect to many Azure, Microsoft, and non-Microsoft services or systems, such as SAP, Salesforce, Oracle, and so on. You can also connect to SaaS applications or in-house applications hosted in virtual networks. When you use these capabilities with AI assistants, you can quickly bring in your data for Intelligent Insights powered by Azure OpenAI.
If you don't have existing workflows, follow these high-level steps to create them:
Set up the following environment variables with information from your Foundry project:
export PROJECT_ENDPOINT="<your_project_endpoint>" export MODEL_DEPLOYMENT_NAME="<your_model_deployment_name>" export SUBSCRIPTION_ID="<your_Azure_subscription_ID>" export resource_group_name="<your_resource_group_name>"
1: Create a logic app resource
To create a logic app resource and workflow for function calling, follow these steps:
In the Azure portal, create a Consumption logic app resource by following these general steps. After you open the workflow designer, return to this section.
On the designer, add the Request trigger named When an HTTP request is received by following these general steps.
Select the Request trigger to open the information pane and follow these steps:
On the information pane, change the trigger name to reflect the function's task, for example:
Function - Get weather forecast for todayProvide the following trigger information:
Parameter Description Description Enter a useful description about the task that the workflow performs, for example: This trigger and workflow gets the weather forecast for today from MSN Weather.Request Body JSON Schema Enter a JSON schema that specifies the expected inputs.
If you don't have a schema, select Use sample payload to generate schema, provide sample input, and select Done.The following image shows an example trigger with a task-relevant name, description, and schema:
On the designer toolbar, select Save to save the workflow.
When you save a Request trigger for the first time, the designer generates the HTTP URL for the trigger's REST endpoint.
Based on your business use case or logic, add one or more actions in this workflow.
For example, to get today's weather forecast for the current location, add an action from the MSN Weather connector. This example uses the Get forecast for today action.
In the action information pane for the Get forecast for today action, follow these steps:
Select inside the Location parameter. When the input options appear (lightning icon and function icon), select the dynamic content list option (lightning icon).
The dynamic content list lets you select outputs from preceding operations in the workflow. In this case, you want the location value that passed through the trigger to the workflow.
From the dynamic content list, under trigger section named Function - Get weather forecast for today, select Location, for example:
The action now looks like the following example:
On the designer, add the Response action by following these general steps.
The workflow returns a response to Foundry by using the Response action.
From the dynamic content list, optionally select any prior operation outputs to return to Foundry. Or, you can provide a JSON schema to return the output in a specific format.
On the designer toolbar, select Save to save the workflow.
Your workflow is now ready to import into Foundry.
2: Import the logic app resource as a function
To bring a logic app resource and workflow into Foundry for function calling through the Assistants playground, follow these steps:
In the Foundry portal (classic), open your Foundry project.
On the project sidebar, select Playgrounds. Scroll down and select Try the Assistants playground.
On the Assistants playground page, open an existing assistant or create a new one.
In the Setup section, expand Tools. Next to Functions, select + Add function, for example:
On the Add a custom function trigger screen, select the Logic Apps tab, for example:
On the Add logic app function screen, from the logic apps list, select a logic app:
Note
The list shows only logic apps with workflows that meet the requirements for function calling.
When you finish, select Save.
The portal returns you to the Assistants playground page. In the Functions section, the successfully imported logic app workflow now appears as a function that your assistant can call, based on the user prompt.
3: Test the logic app function
To confirm that the imported logic app function works as expected, follow these steps:
On the Assistants playground page, in the chat window, enter a query for today's weather forecast in Seattle, for example:
To confirm the logic app function call, review the logs or the workflow run history.
The following example shows a sample log with the function call:
1: Create a project client
Create a client object to connect to your Foundry project.
import os
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
# Create the project client
project_client = AIProjectClient(
endpoint=os.environ["PROJECT_ENDPOINT"],
credential=DefaultAzureCredential(),
)
2: Register the logic app
Provide the trigger name and details to register the logic app resource. To find the AzureLogicAppTool utility code, visit the full sample on GitHub.
from user_logic_apps import AzureLogicAppTool
# Logic app details
LOGIC_APP_NAME = "your_logic_app_name"
TRIGGER_NAME = "your_trigger_name"
# Register the logic app with the agent tool utility
subscription_id = os.environ["SUBSCRIPTION_ID"]
resource_group = os.environ["resource_group_name"]
logic_app_tool = AzureLogicAppTool(subscription_id, resource_group)
logic_app_tool.register_logic_app(LOGIC_APP_NAME, TRIGGER_NAME)
print(f"Registered logic app '{LOGIC_APP_NAME}' with trigger '{TRIGGER_NAME}'.")
3: Create an agent with the logic app tool
Create an agent and attach the logic app as a function tool.
from azure.ai.agents.models import ToolSet, FunctionTool
from user_functions import fetch_current_datetime
from user_logic_apps import create_send_email_function
# Create the logic app function for the agent toolset
send_email_func = create_send_email_function(
logic_app_tool, LOGIC_APP_NAME
)
functions_to_use = {fetch_current_datetime, send_email_func}
# Build and assign the toolset
functions = FunctionTool(functions=functions_to_use)
toolset = ToolSet()
toolset.add(functions)
agent = project_client.agents.create_agent(
model=os.environ["MODEL_DEPLOYMENT_NAME"],
name="SendEmailAgent",
instructions="You are a specialized agent for sending emails.",
toolset=toolset,
)
print(f"Created agent, ID: {agent.id}")
4: Create a thread
Create a thread and add a user message to start the conversation.
RECIPIENT_EMAIL = "your_recipient@example.com"
# Create a thread for communication
thread = project_client.agents.threads.create()
print(f"Created thread, ID: {thread.id}")
# Create a message in the thread
message = project_client.agents.messages.create(
thread_id=thread.id,
role="user",
content=f"Send an email to {RECIPIENT_EMAIL} with the current date and time.",
)
print(f"Created message, ID: {message.id}")
5: Run the agent and check the output
Create a run and confirm that the agent uses the logic app tool to complete the task.
# Run the agent on the thread
run = project_client.agents.runs.create_and_process(
thread_id=thread.id, agent_id=agent.id
)
print(f"Run finished with status: {run.status}")
if run.status == "failed":
print(f"Run failed: {run.last_error}")
# Fetch and display all messages
messages = project_client.agents.messages.list(thread_id=thread.id)
for msg in messages:
if msg.text_messages:
last_text = msg.text_messages[-1]
print(f"{msg.role}: {last_text.text.value}")
6: Clean up resources
Delete the agent when you're done to clean up resources.
# Delete the agent
project_client.agents.delete_agent(agent.id)
print("Deleted agent")
FAQ
What happens when you add a logic app workflow as a function?
Azure Logic Apps publishes an OpenAPI 2.0 definition (swagger) for workflows with a Request trigger, based on workflow annotations. Foundry uses this swagger file to generate a function specification and populate the function definition that the AI assistant requires. The trigger schema and description come from the configuration you set up in the Request trigger. You can edit the swagger by updating your workflow.
To view the function specification in Foundry, follow these steps:
On the Assistants playground page, in the Setup section, go to the Functions section.
Next to the function, from the ellipses menu (...), select Manage.
The following screenshot shows a sample function specification for the example function:
How does authentication work for calls from Foundry to Azure Logic Apps?
Azure Logic Apps supports the following types of authentication for inbound calls from Foundry to the Request trigger in a logic app workflow:
Shared Access Signature (SAS) based authentication
When an AI assistant calls a function that runs a logic app workflow, Foundry sends a request to the callback URL in the workflow's Request trigger. You can get this callback URL, which includes an SAS, by using Workflows - List callback Url from the REST API for Azure Logic Apps.
For SAS authentication, Azure Logic Apps also supports the following tasks:
- Create SAS URLs with a specified validity period.
- Use multiple keys and rotate them as needed.
For more information, see Generate a Shared Access Signature (SAS) key or token.
Microsoft Entra ID-based OAuth authentication policy
Azure Logic Apps supports authentication for calls to request triggers by using OAuth with Microsoft Entra ID. You can specify authentication policies to use when validating OAuth tokens. For more information, see Enable OAuth 2.0 with Microsoft Entra ID in Azure Logic Apps.
For more information about securing inbound calls in Azure Logic Apps, see Access for inbound calls to request-based triggers.