- Upload files and create a vector store
- Configure an agent with file search enabled
- Query your documents through the agent
By using the standard agent setup, the improved file search tool ensures your files remain in your own storage. Your Azure AI Search resource ingests the files, so you maintain complete control over your data.
File search has additional charges beyond the token-based fees for model usage.
Usage support
The following table shows SDK and setup support.Prerequisites
- A basic or standard agent environment
- The SDK package for your language:
- Python:
azure-ai-projects(latest) - .NET:
Azure.AI.Extensions.OpenAI - TypeScript:
@azure/ai-projects(latest) - Java:
azure-ai-agents
- Python:
- Storage Blob Data Contributor role on your project’s storage account (required for uploading files to your project’s storage)
- Foundry Owner role on your Foundry resource (required for creating agent resources)
The Foundry RBAC roles were recently renamed. Foundry User, Foundry Owner, Foundry Account Owner, and Foundry Project Manager were previously named Azure AI User, Azure AI Owner, Azure AI Account Owner, and Azure AI Project Manager. You might still see the previous names in some places while the rename rolls out. The role IDs and core permissions are unchanged by the rename.
- Azure credentials configured for authentication (such as
DefaultAzureCredential). - Your Foundry project endpoint URL and model deployment name.
Code examples
The following examples show how to upload a file, create a vector store, configure an agent with file search enabled, and query the agent.Verify file search results
After running a code sample in this article, verify that file search is working:- Confirm that the vector store and file are created.
- In the Python and TypeScript samples, the upload-and-poll helpers complete only after ingestion finishes.
- Ask a question that you can answer only from your uploaded content.
- Confirm that the response is grounded in your documents.
File sources
- Upload local files (Basic and Standard agent setup)
- Azure Blob Storage (Standard setup only)
File search behavior by agent setup type
Basic agent setup
The file search tool has the same functionality as Azure OpenAI Responses API. The tool uses Microsoft managed search and storage resources.- You store uploaded files in Microsoft managed storage.
- You create a vector store by using a Microsoft managed search resource.
Standard agent setup
The file search tool uses the Azure AI Search and Azure Blob Storage resources you connect to during agent setup.- You store uploaded files in your connected Azure Blob Storage account.
- You create vector stores by using your connected Azure AI Search resource.
- Automatically parsing and chunking documents.
- Generating and storing embeddings.
- Utilizing both vector and keyword searches to retrieve relevant content for user queries.
When to use file search
Choose file search when you need to:- Search through documents you upload directly (PDFs, Word docs, code files)
- Enable agents to answer questions from proprietary or confidential content
- Process files up to 512 MB without managing external search infrastructure
How file search works
The file search tool uses retrieval best practices to extract relevant data from your files and improve model responses.Query processing
When you send a query, file search:- Rewrites your query to optimize it for search.
- Breaks down complex queries into parallel searches.
- Runs hybrid search combining keyword and semantic matching across vector stores.
- Reranks results to select the most relevant content for the response.
Default chunking settings
Vector stores
Vector store objects give the file search tool the ability to search your files. When you add a file to a vector store, the process automatically parses, chunks, embeds, and stores the file in a vector database that supports both keyword and semantic search. Each vector store can hold up to 10,000 files. You can attach vector stores to both agents and conversations. Currently, you can attach at most one vector store to an agent and at most one vector store to a conversation. For background concepts and lifecycle guidance (readiness, deletion behavior, and expiration policies), see Vector stores for file search. Remove files from a vector store by:- Deleting the vector store file object.
- Deleting the underlying file object. This action removes the file from all
vector_storeandcode_interpreterconfigurations across all agents and conversations in your organization.
Ensuring vector store readiness before creating runs
Ensure the system fully processes all files in a vector store before you create a run. This ensures all data in your vector store is searchable. Check for vector store readiness by using the polling helpers in the SDKs, or by manually polling the vector store object to ensure the status is completed. As a fallback, the run object includes a 60-second maximum wait when the conversation’s vector store contains files that are still processing. This wait ensures that any files your users upload in a conversation are fully searchable before the run proceeds. This fallback wait doesn’t apply to the agent’s vector store.Conversation vector stores have default expiration policies
Vector stores that you create by using conversation helpers (liketool_resources.file_search.vector_stores in conversations or message.attachments in Messages) have a default expiration policy of seven days after they were last active (defined as the last time the vector store was part of a run).
When a vector store expires, the runs on that conversation fail. To fix this problem, recreate a new vector store with the same files and reattach it to the conversation.
Supported file types
For text MIME types, the encoding must be UTF-8, UTF-16, or ASCII.
Limitations
Keep these limits in mind when you plan your file search integration:- File search supports specific file formats and encodings. See Supported file types.
- Each vector store can hold up to 10,000 files.
- You can attach at most one vector store to an agent and at most one vector store to a conversation.
- Features and availability vary by region. See Azure AI Foundry region support.
Troubleshooting
Related content
- Azure AI Search tool - Search existing Azure AI Search indexes from your agents
- Web search tool - Enable agents to search the public web
- Vector stores for file search - Understand vector store lifecycle and expiration
- Structured inputs - Parameterize agent definitions at runtime