Skip to content

Commit b2aeb11

Browse files
committed
updates
1 parent a25ba32 commit b2aeb11

File tree

1 file changed

+9
-107
lines changed
  • articles/ai-services/agents/how-to/tools

1 file changed

+9
-107
lines changed

articles/ai-services/agents/how-to/tools/fabric.md

Lines changed: 9 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services: cognitive-services
66
manager: nitinme
77
ms.service: azure-ai-agent-service
88
ms.topic: how-to
9-
ms.date: 03/27/2025
9+
ms.date: 02/25/2025
1010
author: aahill
1111
ms.author: aahi
1212
zone_pivot_groups: selection-fabric-data-agent
@@ -25,7 +25,7 @@ You need to first build and publish a Fabric data agent and then connect your Fa
2525

2626
|Azure AI foundry support | Python SDK | C# SDK | JavaScript SDK | REST API |Basic agent setup | Standard agent setup |
2727
|---------|---------|---------|---------|---------|---------|---------|
28-
| ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
28+
| ✔️ | ✔️ | - | ✔️ | ✔️ | ✔️ | ✔️ |
2929

3030
## Prerequisites
3131
1. You have created and published a Fabric data agent endpoint
@@ -37,6 +37,7 @@ You need to first build and publish a Fabric data agent and then connect your Fa
3737
## Setup
3838
> [!NOTE]
3939
> 1. The model you selected in Azure AI Agent setup is only used for agent orchestration and response generation. It doesn't impact which model Fabric data agent uses for NL2SQL operation.
40+
> 1. Supported regions: `westus`, `japaneast` more regions are coming soon.
4041
1. Create an Azure AI Agent by following the steps in the [quickstart](../../quickstart.md).
4142

4243
1. Create and publish a [Fabric data agent](/fabric/data-science/how-to-create-data-agent)
@@ -68,27 +69,6 @@ from azure.ai.projects import AIProjectClient
6869
from azure.identity import DefaultAzureCredential
6970
from azure.ai.projects.models import FabricTool
7071
```
71-
72-
# [C#](#tab/csharp)
73-
74-
```csharp
75-
using System;
76-
using System.Collections.Generic;
77-
using System.Threading.Tasks;
78-
using Azure.Core;
79-
using Azure.Core.TestFramework;
80-
using NUnit.Framework;
81-
82-
var connectionString = TestEnvironment.AzureAICONNECTIONSTRING;
83-
84-
var clientOptions = new AIProjectClientOptions();
85-
86-
// Adding the custom headers policy
87-
clientOptions.AddPolicy(new CustomHeadersPolicy(), HttpPipelinePosition.PerCall);
88-
var projectClient = new AIProjectClient(connectionString, new DefaultAzureCredential(), clientOptions);
89-
90-
```
91-
9272
# [JavaScript](#tab/javascript)
9373

9474
```javascript
@@ -131,38 +111,13 @@ fabric = FabricTool(connection_id=conn_id)
131111
with project_client:
132112
agent = project_client.agents.create_agent(
133113
model="gpt-4o",
134-
name="my-agent",
135-
instructions="You are a helpful agent",
114+
name="my-assistant",
115+
instructions="You are a helpful assistant",
136116
tools=fabric.definitions,
137117
headers={"x-ms-enable-preview": "true"},
138118
)
139119
print(f"Created agent, ID: {agent.id}")
140120
```
141-
142-
# [C#](#tab/csharp)
143-
144-
```csharp
145-
ConnectionResponse fabricConnection = await projectClient.GetConnectionsClient().GetConnectionAsync("<FABRICCONNECTIONNAME>");
146-
var connectionId = fabricConnection.Id;
147-
148-
AgentsClient agentClient = projectClient.GetAgentsClient();
149-
150-
ToolConnectionList connectionList = new ToolConnectionList
151-
{
152-
ConnectionList = { new ToolConnection(connectionId) }
153-
};
154-
MicrosoftFabricToolDefinition fabricGroundingTool = new MicrosoftFabricToolDefinition(connectionList);
155-
156-
Response<Agent> agentResponse = await agentClient.CreateAgentAsync(
157-
model: modelName,
158-
name: "my-agent-fabric01",
159-
instructions: "You are a helpful agent. Use the fabric tool to answer questions.",
160-
tools: new List<ToolDefinition> { fabricGroundingTool });
161-
Agent agent = agentResponse.Value;
162-
Console.Write($"agent id: {agent.Id}");
163-
Console.WriteLine();
164-
```
165-
166121
# [JavaScript](#tab/javascript)
167122

168123
```javascript
@@ -174,7 +129,7 @@ const connectionId = fabricConnection.id;
174129
// Initialize agent Microsoft Fabric tool with the connection id
175130
const fabricTool = ToolUtility.createFabricTool(connectionId);
176131

177-
// Create agent with the Microsoft Fabric tool and process the agent run
132+
// Create agent with the Microsoft Fabric tool and process assistant run
178133
const agent = await client.agents.createAgent("gpt-4o", {
179134
name: "my-agent",
180135
instructions: "You are a helpful agent",
@@ -208,7 +163,6 @@ curl $AZURE_AI_AGENTS_ENDPOINT/assistants?api-version=2024-12-01-preview \
208163
]
209164
}'
210165
```
211-
212166
---
213167

214168
## Step 3: Create a thread
@@ -229,22 +183,6 @@ message = project_client.agents.create_message(
229183
)
230184
print(f"Created message, ID: {message.id}")
231185
```
232-
233-
# [C#](#tab/csharp)
234-
235-
```csharp
236-
// Create thread for communication
237-
Response<AgentThread> threadResponse = await agentClient.CreateThreadAsync();
238-
AgentThread thread = threadResponse.Value;
239-
240-
// Create message to thread
241-
Response<ThreadMessage> messageResponse = await agentClient.CreateMessageAsync(
242-
thread.Id,
243-
MessageRole.User,
244-
"<ask a question related to your Fabric data>");
245-
ThreadMessage message = messageResponse.Value;
246-
```
247-
248186
# [JavaScript](#tab/javascript)
249187

250188
```javascript
@@ -297,7 +235,7 @@ print(f"Run finished with status: {run.status}")
297235
if run.status == "failed":
298236
print(f"Run failed: {run.last_error}")
299237

300-
# Delete the agent when done
238+
# Delete the assistant when done
301239
project_client.agents.delete_agent(agent.id)
302240
print("Deleted agent")
303241

@@ -306,43 +244,6 @@ messages = project_client.agents.list_messages(thread_id=thread.id)
306244
print(f"Messages: {messages}")
307245
```
308246

309-
# [C#](#tab/csharp)
310-
311-
```csharp
312-
// Run the agent
313-
Response<ThreadRun> runResponse = await agentClient.CreateRunAsync(thread, agent);
314-
315-
do
316-
{
317-
await Task.Delay(TimeSpan.FromMilliseconds(500));
318-
runResponse = await agentClient.GetRunAsync(thread.Id, runResponse.Value.Id);
319-
}
320-
while (runResponse.Value.Status == RunStatus.Queued
321-
|| runResponse.Value.Status == RunStatus.InProgress);
322-
323-
Response<PageableList<ThreadMessage>> afterRunMessagesResponse
324-
= await agentClient.GetMessagesAsync(thread.Id);
325-
IReadOnlyList<ThreadMessage> messages = afterRunMessagesResponse.Value.Data;
326-
327-
// Note: messages iterate from newest to oldest, with the messages[0] being the most recent
328-
foreach (ThreadMessage threadMessage in messages)
329-
{
330-
Console.Write($"{threadMessage.CreatedAt:yyyy-MM-dd HH:mm:ss} - {threadMessage.Role,10}: ");
331-
foreach (MessageContent contentItem in threadMessage.ContentItems)
332-
{
333-
if (contentItem is MessageTextContent textItem)
334-
{
335-
Console.Write(textItem.Text);
336-
}
337-
else if (contentItem is MessageImageFileContent imageFileItem)
338-
{
339-
Console.Write($"<image from ID: {imageFileItem.FileId}");
340-
}
341-
Console.WriteLine();
342-
}
343-
}
344-
```
345-
346247
# [JavaScript](#tab/javascript)
347248

348249
```javascript
@@ -390,6 +291,7 @@ for (let i = messages.data.length - 1; i >= 0; i--) {
390291
}
391292
}
392293
```
294+
---
393295
394296
# [REST API](#tab/rest)
395297
### Run the thread
@@ -423,4 +325,4 @@ curl $AZURE_AI_AGENTS_ENDPOINT/threads/thread_abc123/messages?api-version=2024-1
423325
424326
## Next steps
425327
426-
[See the full sample for Fabric data agent.](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/ai/azure-ai-projects/samples/agents/sample_agents_fabric.py)
328+
[See the full sample for Fabric data agent.](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/ai/azure-ai-projects/samples/agents/sample_agents_fabric.py)

0 commit comments

Comments
 (0)