Hello Umesh,
You're close, but the issue stems from how the function is registered and used in Azure Agentic AI's FunctionTool
ERROR:root:Error executing function 'fetch_weather': Function 'fetch_weather' not found.
This error means the function name is not being correctly matched or not registered in the internal function registry that FunctionTool
uses.
You must ensure the function is wrapped correctly and registered with its name string so the agent can look it up.
Import the required Azure classes
Make sure you're importing the right classes from azure.ai.services.agents.tools
.
from azure.ai.services.agents.tools import FunctionTool, ToolSet
Use a FunctionTool
with proper function name mapping
Update your code like this:
import json
from azure.ai.services.agents.tools import FunctionTool, ToolSet
Step 1: Define the function
def fetch_weather(location: str) -> str:
mock_weather_data = {
"New York": "Sunny, 25°C",
"London": "Cloudy, 18°C",
"Tokyo": "Rainy, 22°C"
}
weather = mock_weather_data.get(location, "Weather data not available for this location.")
return json.dumps({"weather": weather})
Step 2: Create a FunctionTool instance
weather_tool = FunctionTool(fetch_weather)
Step 3: Create a ToolSet and register the tool
toolset = ToolSet()
toolset. Add(weather_tool)
This ensures:
The function fetch_weather
is registered by its actual name.
-
FunctionTool
wraps the function correctly for the Azure Agent runtime.
Problem in Your Current Code
user_functions: Set[Callable[..., Any]] = {
fetch_weather,
}
functions = FunctionTool(user_functions)
This incorrectly passes a set of functions instead of individual ones. FunctionTool()
expects one function at a time, not a set.
Make sure the tool is referenced with the exact name the function defines (fetch_weather
in this case) — Agentic AI resolves the name via introspection.
Best Regards,
Jerald Felix