Skip to content

Commit 3458355

Browse files
committed
adding azure blob storage code examples
1 parent 58bf6c6 commit 3458355

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

articles/ai-services/agents/how-to/tools/file-search.md

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ As a fallback, there's a 60-second maximum wait in the run object when the threa
8383

8484
::: zone-end
8585

86-
::: zone pivot="code-examples"
86+
::: zone pivot="upload-files-code-examples"
8787

8888
## Quickstart – Upload Local Files with file search
8989

@@ -106,7 +106,7 @@ from azure.identity import DefaultAzureCredential
106106

107107

108108
# Create an Azure AI Client from a connection string, copied from your AI Studio project.
109-
# At the moment, it should be in the format "<HostName>;<AzureSubscriptionId>;<ResourceGroup>;<HubName>"
109+
# At the moment, it should be in the format "<HostName>;<AzureSubscriptionId>;<ResourceGroup>;<ProjectName>"
110110
# Customer needs to login to Azure subscription via Azure CLI and set the environment variables
111111

112112
credential = DefaultAzureCredential()
@@ -126,7 +126,7 @@ using Azure.Core.TestFramework;
126126
using NUnit.Framework;
127127

128128
// Create an Azure AI Client from a connection string, copied from your AI Studio project.
129-
// At the moment, it should be in the format "<HostName>;<AzureSubscriptionId>;<ResourceGroup>;<HubName>"
129+
// At the moment, it should be in the format "<HostName>;<AzureSubscriptionId>;<ResourceGroup>;<ProjectName>"
130130
// Customer needs to login to Azure subscription via Azure CLI and set the environment variables
131131
var connectionString = TestEnvironment.AzureAICONNECTIONSTRING;
132132
AgentsClient client = new AgentsClient(connectionString, new DefaultAzureCredential());
@@ -145,7 +145,7 @@ Vector stores are created using message attachments that have a default expirati
145145
```python
146146
# We will upload the local file to Azure and will use it for vector store creation.
147147
_, asset_uri = project_client.upload_file("./data/product_info_1.md")
148-
148+
print(f"Uploaded file, asset URI: {asset_uri}")
149149
# create a vector store with no file and wait for it to be processed
150150
ds = VectorStoreDataSource(asset_identifier=asset_uri, asset_type=VectorStoreDataSourceAssetType.URI_ASSET)
151151
vector_store = project_client.agents.create_vector_store_and_poll(data_sources=[ds], name="sample_vector_store")
@@ -301,6 +301,37 @@ foreach (ThreadMessage threadMessage in messages)
301301

302302
::: zone-end
303303

304+
::: zone pivot="azure-blob-storage-code-examples"
305+
## Quickstart – Use existing files in Azure Blob Storage with file search
306+
In this example, we’ll use Azure AI Agent Service to create an agent that can help answer questions on information from files in Azure Blob Storage.
307+
308+
### Prerequisites
309+
Complete the [standard agent setup](../../quickstart.md).
310+
311+
> [!NOTE]
312+
> Azure Blob Storage is only available with the standard agent setup. The basic agent setup does not support this file source.
313+
314+
### Step 1: Create a project client
315+
# [Python](#tab/python)
316+
317+
```python
318+
import os
319+
from azure.ai.projects import AIProjectClient
320+
from azure.ai.projects.models import FileSearchTool, VectorStoreDataSource, VectorStoreDataSourceAssetType
321+
from azure.identity import DefaultAzureCredential
322+
323+
324+
# Create an Azure AI Client from a connection string, copied from your AI Studio project.
325+
# At the moment, it should be in the format "<HostName>;<AzureSubscriptionId>;<ResourceGroup>;<ProjectName>"
326+
# Customer needs to login to Azure subscription via Azure CLI and set the environment variables
327+
328+
credential = DefaultAzureCredential()
329+
project_client = AIProjectClient.from_connection_string(
330+
credential=credential, conn_str=os.environ["PROJECT_CONNECTION_STRING"]
331+
)
332+
```
333+
334+
::: zone-end
304335
::: zone pivot="supported-filetypes"
305336

306337
### Supported file types

zone-pivots/zone-pivot-groups.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -934,8 +934,10 @@ groups:
934934
pivots:
935935
- id: overview
936936
title: Overview
937-
- id: code-examples
938-
title: Code examples
937+
- id: upload-files-code-examples
938+
title: Upload files code examples
939+
- id: azure-blob-storage-code-examples
940+
title: Azure Blob Storage code examples
939941
- id: supported-filetypes
940942
title: Supported file types
941943
- id: deep-dive

0 commit comments

Comments
 (0)