本页还没有译文
本页 41 段还没译成한국어,下面显示的是英文原文。Azure Logic Apps integration
还没翻译译自英文(docs.langchain.com)本页 41 段都还没译
This page covers the Azure Logic Apps integration from langchain_azure_ai.tools.
Azure Logic Apps is a cloud service that helps you automate workflows and business processes. You can use the AzureLogicAppTool to invoke pre-configured Logic App workflows from your LangChain agents, enabling automation, notifications, data synchronization, and orchestration of multi-step processes.
Overview
The AzureLogicAppTool allows agents to trigger Azure Logic Apps workflows by sending JSON payloads to named triggers. This is useful for automating tasks like sending emails, processing data, calling APIs, or integrating with other Azure and third-party services.
Common use cases:
- Email notifications - Send alerts and notifications via Logic App
- Data synchronization - Sync data between systems
- Order processing - Trigger order fulfillment workflows
- API integrations - Call external APIs through Logic Apps
- Approval workflows - Start approval processes
- Data transformation - Process and transform data
- Multi-step automation - Orchestrate complex business processes
Setup
Install the integration package and configure your Azure credentials.
Installation
Install the package with the tools extra:
pip install -U "langchain-azure-ai[tools]"uv add "langchain-azure-ai[tools]"This extra installs the required azure-mgmt-logic dependency.
Prerequisites
Before using this tool, you need:
- An Azure subscription
- An Azure Logic App with at least one HTTP request trigger
- The subscription ID, resource group name, Logic App name, and trigger name
Credentials
The tool uses DefaultAzureCredential() by default, which supports various authentication methods including environment variables, managed identity, and interactive login.
from azure.identity import DefaultAzureCredential
credential = DefaultAzureCredential()You can also pass a specific credential explicitly:
from azure.identity import ManagedIdentityCredential
credential = ManagedIdentityCredential()Basic usage
Instantiate the tool
from langchain_azure_ai.tools import AzureLogicAppTool
tool = AzureLogicAppTool(
subscription_id="<your-subscription-id>",
resource_group="<your-resource-group>",
logic_app_name="<your-logic-app-name>",
trigger_name="<your-trigger-name>",
)Invoke the tool
import json
# Simple text input
result = tool.invoke("Send an email notification")
print(result)
# JSON payload input
payload = {
"email": "user@example.com",
"subject": "Test Email",
"message": "This is a test message from a Logic App trigger."
}
result = tool.invoke(json.dumps(payload))
print(result)Use with an agent
Pass the tool to create_agent.
from azure.identity import DefaultAzureCredential
from langchain.agents import create_agent
from langchain.chat_models import init_chat_model
from langchain_azure_ai.tools import AzureLogicAppTool
credential = DefaultAzureCredential()
tool = AzureLogicAppTool(
subscription_id="<your-subscription-id>",
resource_group="<your-resource-group>",
logic_app_name="notification-workflow",
trigger_name="manual_trigger",
credential=credential,
)
agent = create_agent(
model=init_chat_model("azure_ai:gpt-4.1", credential=credential),
tools=[tool],
system_prompt=(
"You are a workflow automation assistant. Use the Logic Apps tool to trigger "
"workflows for sending notifications, processing data, or integrating with "
"other services when users request automation tasks."
),
)Configuration
Parameters
Configuration options
subscription_id str required
Your Azure subscription ID where the Logic Apps are hosted.
resource_group str required
The Azure Resource Group name where the Logic App is deployed.
logic_app_name str required
The name of the Logic App workflow to invoke.
trigger_name str required
The name of the trigger in the Logic App to invoke. Typically this is manual_trigger or http_request for HTTP request-based triggers.
credential TokenCredential | None default: None
Optional Azure credential for authentication. If None, DefaultAzureCredential() is used. Can be any Azure SDK credential such as ManagedIdentityCredential, ClientSecretCredential, etc.
name str default: azure_logic_app_tool
The name of the tool. Customize this for different Logic Apps or use cases.
description str
A description of the tool's purpose. Customize this to help the agent understand when to use this specific Logic App.
Input format
The tool accepts input as either:
- Plain text - Automatically converted to JSON with an
inputkey - JSON string - Parsed and sent as-is to the Logic App trigger
Examples
# Plain text input
tool.invoke("Process this order")
# Sent as: {"input": "Process this order"}
# JSON payload
import json
payload = {
"orderId": "12345",
"customerEmail": "customer@example.com",
"items": ["item1", "item2"]
}
tool.invoke(json.dumps(payload))Response format
The tool returns a JSON response indicating success or failure:
{
"result": "Successfully invoked <logic-app-name>."
}Or on error:
{
"error": "Error invoking <logic-app-name> (HTTP_STATUS): ERROR_DETAILS"
}API reference
from langchain_azure_ai.tools import AzureLogicAppTool