Skip to content

Commit 9583943

Browse files
Merge pull request #53359 from buzahid/ai-agents
Added new unit to Foundry workflows module
2 parents 7ce0e7f + 9eb1d4b commit 9583943

9 files changed

Lines changed: 99 additions & 2 deletions

File tree

learn-pr/wwl-data-ai/.openpublishing.redirection.wwl-data-ai.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5144,6 +5144,18 @@
51445144
"source_path_from_root": "/learn-pr/wwl-data-ai/get-started-generative-ai-azure-database-postgresql/9-summary.yml",
51455145
"redirect_url": "/training/modules/get-started-generative-ai-azure-database-postgresql",
51465146
"redirect_document_id": false
5147+
},
5148+
{
5149+
"source_path_from_root": "/learn-pr/wwl-data-ai/build-agent-workflows-microsoft-foundry/8-exercise.yml",
5150+
"redirect_url": "/training/modules/build-agent-workflows-microsoft-foundry/9-exercise"
5151+
},
5152+
{
5153+
"source_path_from_root": "/learn-pr/wwl-data-ai/build-agent-workflows-microsoft-foundry/9-knowledge-check.yml",
5154+
"redirect_url": "/training/modules/build-agent-workflows-microsoft-foundry/10-knowledge-check"
5155+
},
5156+
{
5157+
"source_path_from_root": "/learn-pr/wwl-data-ai/build-agent-workflows-microsoft-foundry/10-summary.yml",
5158+
"redirect_url": "/training/modules/build-agent-workflows-microsoft-foundry/11-summary"
51475159
}
51485160
]
51495161
}

learn-pr/wwl-data-ai/build-agent-workflows-microsoft-foundry/9-knowledge-check.yml renamed to learn-pr/wwl-data-ai/build-agent-workflows-microsoft-foundry/10-knowledge-check.yml

File renamed without changes.

learn-pr/wwl-data-ai/build-agent-workflows-microsoft-foundry/10-summary.yml renamed to learn-pr/wwl-data-ai/build-agent-workflows-microsoft-foundry/11-summary.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ metadata:
1010
ms.topic: unit
1111
durationInMinutes: 1
1212
content: |
13-
[!include[](includes/10-summary.md)]
13+
[!include[](includes/11-summary.md)]
1414
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.build-agent-workflows-microsoft-foundry.use-workflows-in-code
3+
title: Use workflows in code
4+
metadata:
5+
title: Use Workflows in Code
6+
description: Learn how to invoke and manage workflows programmatically in Microsoft Foundry.
7+
author: buzahid
8+
ms.author: buzahid
9+
ms.date: 2/5/2026
10+
ms.topic: unit
11+
durationInMinutes: 5
12+
content: |
13+
[!include[](includes/8-use-workflows-in-code.md)]
14+

learn-pr/wwl-data-ai/build-agent-workflows-microsoft-foundry/8-exercise.yml renamed to learn-pr/wwl-data-ai/build-agent-workflows-microsoft-foundry/9-exercise.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ metadata:
1010
ms.topic: unit
1111
durationInMinutes: 30
1212
content: |
13-
[!include[](includes/8-exercise.md)]
13+
[!include[](includes/9-exercise.md)]
1414
1515

learn-pr/wwl-data-ai/build-agent-workflows-microsoft-foundry/includes/10-summary.md renamed to learn-pr/wwl-data-ai/build-agent-workflows-microsoft-foundry/includes/11-summary.md

File renamed without changes.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
After designing and testing a workflow in the Microsoft Foundry visual designer, you can integrate it into your applications using the Azure AI Projects SDK. This allows you to embed workflow-driven automation into web apps, APIs, backend services, and other software solutions.
2+
3+
Workflows are created in the Foundry portal using the visual designer, which generates the underlying YAML definition. Once a workflow is saved in your project, you can invoke it programmatically by referencing its name. You can also download the workflow's YAML definition from the portal and include it in your codebase.
4+
5+
## Invoke a workflow
6+
7+
Before running a workflow, establish a connection to your Microsoft Foundry project using the `AIProjectClient`. This client handles authentication and provides access to the OpenAI-compatible API for executing conversations and invoking workflows. To run an existing workflow in your project, create a conversation and invoke the workflow by name.
8+
9+
```python
10+
# Reference a workflow created in the Foundry portal
11+
workflow_name = "triage-workflow"
12+
13+
# Create a conversation context for the workflow
14+
conversation = openai_client.conversations.create()
15+
16+
# Execute the workflow, passing input to drive the workflow logic
17+
stream = openai_client.responses.create(
18+
conversation=conversation.id,
19+
extra_body={"agent": {"name": workflow_name, "type": "agent_reference"}},
20+
input="Users can't reset their password from the mobile app.",
21+
stream=True,
22+
)
23+
```
24+
25+
The `input` parameter lets you pass a prompt or message to the workflow, which the workflow can use to drive its logic—such as processing a user request, triaging a support ticket, or answering a question. Depending on how your workflow is designed, this input might be:
26+
27+
- A user question that agents analyze and respond to
28+
- A support ticket description for classification and routing
29+
- A data payload that triggers processing logic
30+
- An empty string that simply starts the workflow without specific input
31+
32+
## Process workflow events
33+
34+
When streaming is enabled, your application receives events as the workflow executes. These events let you display real-time progress, capture agent outputs, and respond to workflow actions.
35+
36+
```python
37+
for event in stream:
38+
if event.type == "response.completed":
39+
print("Workflow completed:")
40+
for message in event.response.output:
41+
if message.content:
42+
for content_item in message.content:
43+
if content_item.type == 'output_text':
44+
print(content_item.text)
45+
if (event.type == "response.output_item.done") and event.item.type == ItemType.WORKFLOW_ACTION:
46+
print(f"Action '{event.item.action_id}' completed with status: {event.item.status}")
47+
```
48+
49+
Common event types include:
50+
51+
| Event Type | Description |
52+
|------------|-------------|
53+
| `response.completed` | The workflow finished executing and returned a final response |
54+
| `response.output_item.done` | An individual output item (such as a workflow action) completed |
55+
56+
By monitoring these events, you can see how the workflow progresses in real-time, or trigger external actions based on workflow state. Alternatively, you can choose to wait for the entire workflow to complete and process the final response without streaming. For workflows that include human-in-the-loop patterns, your application may need to handle pauses where the workflow waits for user input. In these cases, you can send additional messages to the conversation to provide the requested input and resume workflow execution.
57+
58+
## Benefits of code integration
59+
60+
Integrating workflows into your code enables several scenarios:
61+
62+
| Scenario | Benefit |
63+
|----------|---------|
64+
| Web applications | Embed AI-driven workflows directly in user-facing apps |
65+
| APIs and microservices | Expose workflow capabilities through REST endpoints |
66+
| Batch processing | Invoke workflows programmatically for bulk operations |
67+
| Testing and validation | Automate workflow testing as part of CI/CD pipelines |
68+
| Custom interfaces | Build specialized UIs tailored to specific workflow use cases |
69+
70+
By combining the visual design experience of the Foundry portal with the flexibility of code integration, you can create powerful AI-driven solutions that fit seamlessly into your existing software architecture.

learn-pr/wwl-data-ai/build-agent-workflows-microsoft-foundry/includes/8-exercise.md renamed to learn-pr/wwl-data-ai/build-agent-workflows-microsoft-foundry/includes/9-exercise.md

File renamed without changes.

learn-pr/wwl-data-ai/build-agent-workflows-microsoft-foundry/index.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ units:
4242
- learn.wwl.build-agent-workflows-microsoft-foundry.add-agents-to-workflow
4343
- learn.wwl.build-agent-workflows-microsoft-foundry.apply-power-fx
4444
- learn.wwl.build-agent-workflows-microsoft-foundry.maintain-workflows
45+
- learn.wwl.build-agent-workflows-microsoft-foundry.use-workflows-in-code
4546
- learn.wwl.build-agent-workflows-microsoft-foundry.exercise
4647
- learn.wwl.build-agent-workflows-microsoft-foundry.knowledge-check
4748
- learn.wwl.build-agent-workflows-microsoft-foundry.summary

0 commit comments

Comments
 (0)