@@ -6,7 +6,7 @@ services: cognitive-services
6
6
manager : nitinme
7
7
ms.service : azure-ai-agent-service
8
8
ms.topic : how-to
9
- ms.date : 03/27 /2025
9
+ ms.date : 02/25 /2025
10
10
author : aahill
11
11
ms.author : aahi
12
12
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
25
25
26
26
| Azure AI foundry support | Python SDK | C# SDK | JavaScript SDK | REST API | Basic agent setup | Standard agent setup |
27
27
| ---------| ---------| ---------| ---------| ---------| ---------| ---------|
28
- | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
28
+ | ✔️ | ✔️ | - | ✔️ | ✔️ | ✔️ | ✔️ |
29
29
30
30
## Prerequisites
31
31
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
37
37
## Setup
38
38
> [ !NOTE]
39
39
> 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.
40
41
1 . Create an Azure AI Agent by following the steps in the [ quickstart] ( ../../quickstart.md ) .
41
42
42
43
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
68
69
from azure.identity import DefaultAzureCredential
69
70
from azure.ai.projects.models import FabricTool
70
71
```
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
-
92
72
# [ JavaScript] ( #tab/javascript )
93
73
94
74
``` javascript
@@ -131,38 +111,13 @@ fabric = FabricTool(connection_id=conn_id)
131
111
with project_client:
132
112
agent = project_client.agents.create_agent(
133
113
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 " ,
136
116
tools = fabric.definitions,
137
117
headers = {" x-ms-enable-preview" : " true" },
138
118
)
139
119
print (f " Created agent, ID: { agent.id} " )
140
120
```
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
-
166
121
# [ JavaScript] ( #tab/javascript )
167
122
168
123
``` javascript
@@ -174,7 +129,7 @@ const connectionId = fabricConnection.id;
174
129
// Initialize agent Microsoft Fabric tool with the connection id
175
130
const fabricTool = ToolUtility .createFabricTool (connectionId);
176
131
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
178
133
const agent = await client .agents .createAgent (" gpt-4o" , {
179
134
name: " my-agent" ,
180
135
instructions: " You are a helpful agent" ,
@@ -208,7 +163,6 @@ curl $AZURE_AI_AGENTS_ENDPOINT/assistants?api-version=2024-12-01-preview \
208
163
]
209
164
}'
210
165
```
211
-
212
166
---
213
167
214
168
## Step 3: Create a thread
@@ -229,22 +183,6 @@ message = project_client.agents.create_message(
229
183
)
230
184
print (f " Created message, ID: { message.id} " )
231
185
```
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
-
248
186
# [ JavaScript] ( #tab/javascript )
249
187
250
188
``` javascript
@@ -297,7 +235,7 @@ print(f"Run finished with status: {run.status}")
297
235
if run.status == " failed" :
298
236
print (f " Run failed: { run.last_error} " )
299
237
300
- # Delete the agent when done
238
+ # Delete the assistant when done
301
239
project_client.agents.delete_agent(agent.id)
302
240
print (" Deleted agent" )
303
241
@@ -306,43 +244,6 @@ messages = project_client.agents.list_messages(thread_id=thread.id)
306
244
print (f " Messages: { messages} " )
307
245
```
308
246
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
-
346
247
# [ JavaScript] ( #tab/javascript )
347
248
348
249
``` javascript
@@ -390,6 +291,7 @@ for (let i = messages.data.length - 1; i >= 0; i--) {
390
291
}
391
292
}
392
293
` ` `
294
+ ---
393
295
394
296
# [REST API](#tab/rest)
395
297
### Run the thread
@@ -423,4 +325,4 @@ curl $AZURE_AI_AGENTS_ENDPOINT/threads/thread_abc123/messages?api-version=2024-1
423
325
424
326
## Next steps
425
327
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