Skip to content

Commit b43c6b8

Browse files
authored
Merge pull request #53597 from buzahid/ai-agents
Updated exercise link, content freshness reviews for ai modules.
2 parents 0f377e7 + b8c0702 commit b43c6b8

41 files changed

Lines changed: 152 additions & 103 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

learn-pr/wwl-data-ai/build-agent-with-custom-tools/1-introduction.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Introduction
44
metadata:
55
title: Introduction
66
description: "Introduction to building an agent with custom tools."
7-
ms.date: 05/23/2025
7+
ms.date: 02/24/2026
88
author: ivorb
99
ms.author: berryivor
1010
ms.topic: unit

learn-pr/wwl-data-ai/build-agent-with-custom-tools/2-why-use-custom-tools.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Why use custom tools
44
metadata:
55
title: Why use custom tools
66
description: "Understand the benefits of using custom tools with your agent."
7-
ms.date: 05/23/2025
7+
ms.date: 02/24/2026
88
author: ivorb
99
ms.author: berryivor
1010
ms.topic: unit

learn-pr/wwl-data-ai/build-agent-with-custom-tools/3-custom-tool-options.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Options for implementing custom tools
44
metadata:
55
title: Options for implementing custom tools
66
description: "Explore the options for implementing custom tools in your agent."
7-
ms.date: 05/23/2025
7+
ms.date: 02/24/2026
88
author: ivorb
99
ms.author: berryivor
1010
ms.topic: unit

learn-pr/wwl-data-ai/build-agent-with-custom-tools/4-how-use-custom-tools.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: How to integrate custom tools
44
metadata:
55
title: How to integrate custom tools
66
description: "Learn how to integrate custom tools into your agent. This unit covers function calling, Azure Function integration, and OpenAPI specification integration."
7-
ms.date: 05/23/2025
7+
ms.date: 02/24/2026
88
author: ivorb
99
ms.author: berryivor
1010
ms.topic: unit

learn-pr/wwl-data-ai/build-agent-with-custom-tools/5-exercise.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Exercise - Build an agent with custom tools
44
metadata:
55
title: Exercise - Build an agent with custom tools
66
description: "Get interactive experience with building an agent with custom tools."
7-
ms.date: 05/23/2025
7+
ms.date: 02/24/2026
88
author: ivorb
99
ms.author: berryivor
1010
ms.topic: unit

learn-pr/wwl-data-ai/build-agent-with-custom-tools/6-knowledge-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Module assessment
44
metadata:
55
title: Module assessment
66
description: "Check your knowledge of building an agent with custom tools."
7-
ms.date: 05/23/2025
7+
ms.date: 02/24/2026
88
author: ivorb
99
ms.author: berryivor
1010
ms.topic: unit

learn-pr/wwl-data-ai/build-agent-with-custom-tools/7-summary.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Summary
44
metadata:
55
title: Summary
66
description: "Review the key points of using custom tools with your agent."
7-
ms.date: 05/23/2025
7+
ms.date: 02/24/2026
88
author: ivorb
99
ms.author: berryivor
1010
ms.topic: unit

learn-pr/wwl-data-ai/build-agent-with-custom-tools/includes/4-how-use-custom-tools.md

Lines changed: 109 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,37 @@ def recent_snowfall(location: str) -> str:
2020
mock_snow_data = {"Seattle": "0 inches", "Denver": "2 inches"}
2121
snow = mock_snow_data.get(location, "Data not available.")
2222
return json.dumps({"location": location, "snowfall": snow})
23-
24-
user_functions: Set[Callable[..., Any]] = {
25-
recent_snowfall,
26-
}
2723
```
2824

2925
Register the function with your agent using the Azure AI SDK:
3026

3127
```python
32-
# Initialize agent toolset with user functions
33-
functions = FunctionTool(user_functions)
34-
toolset = ToolSet()
35-
toolset.add(functions)
36-
agent_client.enable_auto_function_calls(toolset=toolset)
28+
# Define a function tool for the model to use
29+
function_tool = FunctionTool(
30+
name="recent_snowfall",
31+
parameters={
32+
"type": "object",
33+
"properties": {
34+
"location": {"type": "string", "description": "The city name to check snowfall for."},
35+
},
36+
"required": ["location"],
37+
"additionalProperties": False
38+
},
39+
description="Get recent snowfall totals for a given location.",
40+
strict=True,
41+
)
42+
43+
# Add the function tool to a list of tools for the agent
44+
tools: list[Tool] = [function_tool]
3745

3846
# Create your agent with the toolset
39-
agent = agent_client.create_agent(
40-
model="gpt-4o-mini",
47+
agent = project_client.agents.create_version(
4148
name="snowfall-agent",
42-
instructions="You are a weather assistant tracking snowfall. Use the provided functions to answer questions.",
43-
toolset=toolset
49+
definition=PromptAgentDefinition(
50+
model="gpt-4.1",
51+
instructions="You are a weather assistant tracking snowfall. Use the provided functions to answer questions.",
52+
tools=tools,
53+
)
4454
)
4555
```
4656

@@ -57,33 +67,38 @@ First, develop and deploy your Azure Function. In this example, imagine we have
5767
When your Azure Function is in place, integrate add it to the agent definition as an Azure Function tool:
5868

5969
```python
60-
storage_service_endpoint = "https://<your-storage>.queue.core.windows.net"
61-
62-
azure_function_tool = AzureFunctionTool(
63-
name="get_snowfall",
64-
description="Get snowfall information using Azure Function",
65-
parameters={
66-
"type": "object",
67-
"properties": {
68-
"location": {"type": "string", "description": "The location to check snowfall."},
70+
tool = AzureFunctionTool(
71+
azure_function=AzureFunctionDefinition(
72+
input_binding=AzureFunctionBinding(
73+
storage_queue=AzureFunctionStorageQueue(
74+
queue_name="STORAGE_INPUT_QUEUE_NAME",
75+
queue_service_endpoint="STORAGE_QUEUE_SERVICE_ENDPOINT",
76+
)
77+
),
78+
output_binding=AzureFunctionBinding(
79+
storage_queue=AzureFunctionStorageQueue(
80+
queue_name="STORAGE_OUTPUT_QUEUE_NAME",
81+
queue_service_endpoint="STORAGE_QUEUE_SERVICE_ENDPOINT",
82+
)
83+
),
84+
function=AzureFunctionDefinitionFunction(
85+
name="queue_trigger",
86+
description="Get weather for a given location",
87+
parameters={
88+
"type": "object",
89+
"properties": {"location": {"type": "string", "description": "location to determine weather for"}},
6990
},
70-
"required": ["location"],
71-
},
72-
input_queue=AzureFunctionStorageQueue(
73-
queue_name="input",
74-
storage_service_endpoint=storage_service_endpoint,
75-
),
76-
output_queue=AzureFunctionStorageQueue(
77-
queue_name="output",
78-
storage_service_endpoint=storage_service_endpoint,
79-
),
91+
),
92+
)
8093
)
81-
82-
agent = agent_client.create_agent(
83-
model=os.environ["MODEL_DEPLOYMENT_NAME"],
84-
name="azure-function-agent",
85-
instructions="You are a snowfall tracking agent. Use the provided Azure Function to fetch snowfall based on location.",
86-
tools=azure_function_tool.definitions,
94+
95+
agent = project_client.agents.create_version(
96+
agent_name="MyAgent",
97+
definition=PromptAgentDefinition(
98+
model="gpt-4.1",
99+
instructions="You are a helpful weather assistant. Use the provided Azure Function to get weather information for a location when needed.",
100+
tools=[tool],
101+
),
87102
)
88103
```
89104

@@ -98,71 +113,101 @@ OpenAPI defined tools allow agents to interact with external APIs using standard
98113
99114
### Example: Using an OpenAPI specification
100115

101-
First, create a JSON file ( in this example, called *snowfall_openapi.json*) describing the API.
116+
First, create a JSON file ( in this example, called *weather_openapi.json*) describing the API.
102117

103118
```json
104119
{
105-
"openapi": "3.0.0",
120+
"openapi": "3.1.0",
106121
"info": {
107-
"title": "Snowfall API",
108-
"version": "1.0.0"
122+
"title": "get weather data",
123+
"description": "Retrieves current weather data for a location based on wttr.in.",
124+
"version": "v1.0.0"
109125
},
126+
"servers": [
127+
{
128+
"url": "https://wttr.in"
129+
}
130+
],
131+
"auth": [],
110132
"paths": {
111-
"/snow": {
133+
"/{location}": {
112134
"get": {
113-
"summary": "Get snowfall information",
135+
"description": "Get weather information for a specific location",
136+
"operationId": "GetCurrentWeather",
114137
"parameters": [
115138
{
116139
"name": "location",
117-
"in": "query",
140+
"in": "path",
141+
"description": "City or location to retrieve the weather for",
118142
"required": true,
119143
"schema": {
120144
"type": "string"
121145
}
146+
},
147+
{
148+
"name": "format",
149+
"in": "query",
150+
"description": "Always use j1 value for this parameter",
151+
"required": true,
152+
"schema": {
153+
"type": "string",
154+
"default": "j1"
122155
}
156+
}
123157
],
124158
"responses": {
125159
"200": {
126160
"description": "Successful response",
127161
"content": {
128-
"application/json": {
162+
"text/plain": {
129163
"schema": {
130-
"type": "object",
131-
"properties": {
132-
"location": {"type": "string"},
133-
"snow": {"type": "string"}
134-
}
164+
"type": "string"
135165
}
136166
}
137167
}
168+
},
169+
"404": {
170+
"description": "Location not found"
138171
}
139-
}
172+
},
173+
"deprecated": false
140174
}
141175
}
176+
},
177+
"components": {
178+
"schemes": {}
142179
}
143180
}
144181
```
145182

146183
Then, register the OpenAPI tool in the agent defintion:
147184

148185
```python
149-
from azure.ai.agents.models import OpenApiTool, OpenApiAnonymousAuthDetails
150-
151-
with open("snowfall_openapi.json", "r") as f:
152-
openapi_spec = json.load(f)
186+
from azure.ai.projects.models import OpenApiTool, OpenApiAnonymousAuthDetails
153187

154-
auth = OpenApiAnonymousAuthDetails()
155-
openapi_tool = OpenApiTool(name="snowfall_api", spec=openapi_spec, auth=auth)
188+
with open(weather_asset_file_path, "r") as f:
189+
openapi_weather = cast(dict[str, Any], jsonref.loads(f.read()))
190+
191+
tool = OpenApiTool(
192+
openapi=OpenApiFunctionDefinition(
193+
name="get_weather",
194+
spec=openapi_weather,
195+
description="Retrieve weather information for a location.",
196+
auth=OpenApiAnonymousAuthDetails(),
197+
)
198+
)
156199

157-
agent = agent_client.create_agent(
158-
model="gpt-4o-mini",
159-
name="openapi-agent",
160-
instructions="You are a snowfall tracking assistant. Use the API to fetch snowfall data.",
161-
tools=[openapi_tool]
200+
agent = project_client.agents.create_version(
201+
agent_name="openapi-agent",
202+
definition=PromptAgentDefinition(
203+
model="gpt-4.1",
204+
instructions="You are a weather assistant. Use the API to fetch weather data.",
205+
tools=[openapi_tool],
206+
),
162207
)
163208
```
164209

165-
The agent can now use the OpenAPI tool to fetch snowfall data dynamically.
210+
The agent can now use the OpenAPI tool to fetch weather data dynamically.
166211

167212
> [!NOTE]
168213
> One of the concepts related to agents and custom tools that developers often have difficulty with is the *declarative* nature of the solution. You don't need to write code that explicitly *calls* your custom tool functions - the agent itself decides to call tool functions based on messages in prompts. By providing the agent with functions that have meaningful names and well-documented parameters, the agent can "figure out" when and how to call the function all by itself!

learn-pr/wwl-data-ai/build-agent-with-custom-tools/includes/5-exercise.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Now it's your opportunity to build an agent with custom tools. In this exercise,
55
66
Launch the exercise and follow the instructions.
77

8-
[![Button to launch exercise.](../media/launch-exercise.png)](https://go.microsoft.com/fwlink/?linkid=2309805&azure-portal=true)
8+
[![Button to launch exercise.](../media/launch-exercise.png)](https://go.microsoft.com/fwlink/?linkid=2353623&azure-portal=true)
99

1010
> [!TIP]
1111
> After completing the exercise, if you're finished exploring Azure AI Agents, delete the Azure resources that you created during the exercise.

learn-pr/wwl-data-ai/build-agent-with-custom-tools/index.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ uid: learn.wwl.build-agent-with-custom-tools
33
metadata:
44
title: Integrate custom tools into your agent
55
description: Learn how to build an agent with custom tools using the Microsoft Foundry Agent Service.
6-
ms.date: 08/28/2025
6+
ms.date: 02/24/2026
77
author: ivorb
88
ms.author: berryivor
99
ms.topic: module-standard-task-based

0 commit comments

Comments
 (0)