You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/logic-apps/add-agent-action-create-run-workflow.md
+143-2Lines changed: 143 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ This guide shows how to add an action as a tool for an agent in Foundry. This ac
38
38
39
39
> [!NOTE]
40
40
>
41
-
> This guide refers to the Foundry (classic) portal. For more information, see the [What is Microsoft Foundry](/azure/foundry/what-is-foundry)?
41
+
> This guide refers to the [Microsoft Foundry (classic)](/azure/foundry-classic/what-is-foundry#microsoft-foundry-portals) portal. For more information about the new portal, see the new [Microsoft Foundry portal](/azure/foundry/what-is-foundry)?
42
42
43
43
For more information, see:
44
44
@@ -52,7 +52,7 @@ For more information, see:
52
52
- A [Foundry project](/azure/foundry-classic/how-to/create-projects?tabs=foundry).
53
53
54
54
This project organizes your work and saves the state while you build your AI apps.
55
-
55
+
56
56
If you want to [create a hub project](/azure/foundry-classic/how-to/hub-create-projects?tabs=portal) so you can host your project and set up a team collaboration environment, you need one of the following roles for Microsoft Entra role-based access control (RBAC), based on the [principle of least privilege](/entra/identity-platform/secure-least-privileged-access):
57
57
58
58
-**Contributor** (least privilege)
@@ -110,6 +110,8 @@ This release has the following limitations or known problems:
110
110
111
111
For more information, see [Hosting options for logic app deployments](/azure/logic-apps/logic-apps-overview#create-and-deploy-to-different-environments).
112
112
113
+
:::zone pivot="portal"
114
+
113
115
## 1: Add an action to your agent
114
116
115
117
To set up an action for your agent to run a logic app workflow, follow these steps:
@@ -243,6 +245,129 @@ To try the new agent action by using the **Agents playground**, follow these ste
243
245
244
246
:::image type="content" source="media/add-agent-action-create-run-workflow/test-action.png" alt-text="Screenshot shows Foundry window with Agents playground page, test prompt about London weather with format instructions, and response." lightbox="media/add-agent-action-create-run-workflow/test-action.png":::
245
247
248
+
:::zone-end
249
+
250
+
:::zone pivot="python"
251
+
252
+
## 1: Set the environment variables
253
+
254
+
Set the following environment variables:
255
+
PROJECT_ENDPOINT: The Azure AI Agents endpoint.
256
+
MODEL_DEPLOYMENT_NAME: The deployment name of the AI model.
257
+
SUBSCRIPTION_ID: Your Azure subscription ID.
258
+
resource_group_name: The name of your resource group.
259
+
260
+
For the full sample that shows integrating an agent in Microsoft Foundry with a Consumption logic app in the Azure portal, see []
For the sample code, see the [AzureLogicAppTool utility on GitHub](https://github.com/azure-ai-foundry/foundry-samples/blob/main/samples-classic/python/getting-started-agents/logic_apps/user_logic_apps.py).
265
+
266
+
267
+
## 2: Create a project client
268
+
269
+
To connect to your Foundry project and other resources, follow these steps to create a client object:
270
+
271
+
```python
272
+
import os
273
+
from azure.ai.projects import AIProjectClient
274
+
from azure.identity import DefaultAzureCredential
275
+
276
+
# Initialize the AIProjectClient
277
+
project_client = AIProjectClient(
278
+
endpoint=os.environ["PROJECT_ENDPOINT"],
279
+
credential=DefaultAzureCredential()
280
+
)
281
+
```
282
+
283
+
## 3: Register your logic app
284
+
285
+
Register your Consumption logic app workflow by providing its name and trigger information. For the sample code, see the [AzureLogicAppTool utility on GitHub](https://github.com/azure-ai-foundry/foundry-samples/blob/main/samples-classic/python/getting-started-agents/logic_apps/user_logic_apps.py).
286
+
287
+
```python
288
+
from user_logic_apps import AzureLogicAppTool
289
+
290
+
# Extract subscription and resource group from environment variables
print(f"Registered logic app '{logic_app_name}' with trigger '{trigger_name}'.")
302
+
```
303
+
304
+
## 4: Create an agent and connect a logic app workflow as a tool through an action
305
+
306
+
The following code creates an agent and adds an action that runs a logic app workflow as a tool. For this example, the logic app workflow sends an email.
307
+
308
+
```python
309
+
from azure.ai.agents.models import ToolSet, FunctionTool
310
+
from user_functions import fetch_current_datetime
311
+
from user_logic_apps import create_send_email_function
312
+
313
+
# Create the specialized "send_email_via_logic_app" function
## Optional: Review underlying logic app and workflow
247
372
248
373
After the action runs, you can view the underlying logic app resource and workflow in the Azure portal. You can review the workflow's run history to debug or troubleshoot problems that the workflow might encounter.
@@ -343,6 +468,8 @@ For Foundry, see the following resources:
343
468
344
469
If you don't need the resources that you created for this guide, delete the resources so you don't continue getting charged. You can either follow these steps to delete the resource group that contains these resources, or you can delete each resource individually.
345
470
471
+
:::zone pivot="portal"
472
+
346
473
1. In the Foundry portal, to remove the action from the agent, next to the action name, select the ellipses (**...**) button, and then select **Remove**.
347
474
348
475
1. In the [Azure portal](https://portal.azure.com) title bar search box, enter **resource groups**, and select **Resource groups**.
@@ -353,6 +480,20 @@ If you don't need the resources that you created for this guide, delete the reso
353
480
354
481
1. When the confirmation pane appears, enter the resource group name, and select **Delete**.
355
482
483
+
:::zone-end
484
+
485
+
:::zone-pivot="python"
486
+
487
+
The following code
488
+
489
+
```python
490
+
# Delete the agent
491
+
project_client.agents.delete_agent(agent.id)
492
+
print("Deleted agent.")
493
+
```
494
+
495
+
:::zone-end
496
+
356
497
## Related content
357
498
358
499
-[What are connectors in Azure Logic Apps?](/azure/connectors/introduction)
0 commit comments