Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Microsoft Agent Framework Azure AI Search

Connect Microsoft Agent Framework agents to Azure AI Search for retrieval and vector storage.

  • AzureAISearchContextProvider adds retrieved context to agents using semantic search or Knowledge Base retrieval.
  • AzureAISearchCollection provides asynchronous batch upsert, get, delete, vector search, and keyword-hybrid search.
  • AzureAISearchStore creates collection clients and manages indexes and index aliases.

All three classes are available from agent_framework.azure or agent_framework_azure_ai_search. The vector collection and store APIs are experimental.

Installation

Supports Python 3.11–3.15.

pip install agent-framework-azure-ai-search --pre

Connection and authentication

You need an Azure AI Search service and permission to query its indexes. Writing documents or managing indexes requires additional permissions. Existing indexes must match your record model; semantic search requires a suitable semantic configuration, and Knowledge Base retrieval requires a configured Knowledge Base.

Set AZURE_SEARCH_ENDPOINT and AZURE_SEARCH_API_KEY, or pass endpoint and api_key explicitly. API keys accept strings or Agent Framework SecretString. For Microsoft Entra ID authentication, install azure-identity and pass an async Azure token credential as credential instead of an API key. See Azure AI Search role-based access.

The package uses AzureAISearchSettings and Agent Framework settings resolution: explicit values override the file selected by env_file_path, then environment variables. env_file_encoding defaults to UTF-8. For the context provider, select an index with index_name or AZURE_SEARCH_INDEX_NAME; for agentic mode, use mode="agentic" and knowledge_base_name or AZURE_SEARCH_KNOWLEDGE_BASE_NAME. Attach the provider through your agent's context_provider parameter.

In agentic mode, pass knowledge_source_params to set per-source retrieval options, such as SearchIndexKnowledgeSourceParams(knowledge_source_name=..., filter_add_on=...). Each entry replaces the provider's defaults for the source with the same name.

Injected SDK clients bypass connection settings and remain caller-owned unless managed_client=True. Use async context managers to close owned store/collection clients; credentials and embedding clients remain caller-owned.

Vector collections and stores (experimental)

This example queries an existing documents index with id, text, and a three-dimensional vector field. Replace the example vector with an embedding from the same model and dimensions used by your index.

import asyncio
from dataclasses import dataclass
from typing import Annotated

from agent_framework import VectorStoreField, vectorstoremodel
from agent_framework.azure import AzureAISearchStore


@vectorstoremodel
@dataclass
class Document:
    id: Annotated[str, VectorStoreField("key")]
    text: Annotated[str, VectorStoreField("data", is_full_text_indexed=True)]
    vector: Annotated[list[float] | None, VectorStoreField("vector", dimensions=3)] = None


async def main():
    async with AzureAISearchStore() as store:
        documents = store.get_collection(Document, collection_name="documents")
        async for result in await documents.search(vector=[1.0, 0.0, 0.0], top=3):
            print(result["record"].text, result["score"])


asyncio.run(main())

Use ensure_collection_exists() to create an absent index; it never updates an existing index. CRUD methods accept batches and require application-provided string keys of 1-1,024 ASCII letters, digits, -, _, or =, without a leading _. Uploads are split by both the 1,000-action and 16 MiB request limits. All keys, vector values, and individual document sizes are checked before the first upload; service-side batch failures can still partially persist records.

Use generate_vectors=False when upserting precomputed vectors, or configure an embedding generator. Text queries without a local generator require an integrated vectorizer on the index. Search targets one top-level dense vector field at a time; binary, sparse, and nested multivector payloads are not supported.

Vector elements must be finite non-boolean numbers within the configured EDM type's range; Edm.SByte and Edm.Int16 fields require integers. Query vectors use the service's floating-point query contract, not the stored field's integer constraints. New vector fields are retrievable by default for include_vectors=True. Set retrievable=False, or stored=False, in the field's azure_ai_search provider annotations to disable vector retrieval. stored=False cannot be combined with retrievable=True. Vector fields cannot be filterable, sortable, facetable, or analyzer-backed.

Portable filters execute in Azure Search. Presence/null filters, ne, null-valued comparisons, empty contains_all, date comparisons, and literal contains_text/starts_with/ends_with are rejected where their semantics cannot be preserved. Use the explicitly tokenized azure_ai_search.match filter operator for full-text matching. Returned scores are Azure @search.score, not raw cosine similarity; hybrid scores use reciprocal rank fusion. not_in excludes null and missing values, matching the portable in-memory behavior.

Stable and preview features

The installed Azure Search SDK selects its API version; the package does not force a preview API. Vector thresholds, hybrid text-recall controls, strict postfiltering, and query-time document permissions require a supporting preview SDK/API and allow_preview=True on the store or collection.

score_threshold applies only to a single pure-vector query. The separate vector_threshold operation option filters vector candidates before hybrid fusion, not final hybrid scores. Unsupported thresholds raise rather than silently falling back. For permission-filtered reads, pass the caller's query_source_credential.

Context-provider answer synthesis, low/medium reasoning effort, and query-time identity also require a supporting preview SDK. Stable Knowledge Base retrieval uses extractive output with minimal reasoning.

Documentation

Metadata

Release files for agent-framework-azure-ai-search 1.0.0b261106

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agent-framework-azure-ai-search 1.0.0b261106
File Size Uploaded Provenance Actions
agent_framework_azure_ai_search-1.0.0b261106.tar.gz 30.8 kB Without provenance Details for agent_framework_azure_ai_search-1.0.0b261106.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for agent-framework-azure-ai-search 1.0.0b261106
File Interpreter ABI Platform Actions
agent_framework_azure_ai_search-1.0.0b261106-py3-none-any.whl Python 3 none any Details for agent_framework_azure_ai_search-1.0.0b261106-py3-none-any.whl

Total release size: 60.7 kB

Release files / agent_framework_azure_ai_search-1.0.0b261106.tar.gz

Download URL agent_framework_azure_ai_search-1.0.0b261106.tar.gz
Size 30.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1fcc339bb315dee9b4fb7ebe96bdcae98f80858f559cbce4c27c44cf5f13e79a
BLAKE2b-256 checksum
How to use checksums
45d1a92dfaf6819d3740690eea19712dd2f9fc238a5e44390978c9697ea7c1d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / agent_framework_azure_ai_search-1.0.0b261106-py3-none-any.whl

Download URL agent_framework_azure_ai_search-1.0.0b261106-py3-none-any.whl
Size 29.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0862e3d9221c3e08e3d936b535f534e5d0b3837e97aee1000c59a579db8c2d45
BLAKE2b-256 checksum
How to use checksums
56642210351a66ede8c607a6b1011d818d0577ddb57597dbc607f8cc940c6d0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Security for agent-framework-azure-ai-search 1.0.0b261106

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page