AGENTIC MEMORY

Skills

Useful instructions for your AI. Search, read and use them through the same MCP connection.

← Back to Skills

azure-ai-projects-py

Build AI applications using the Azure AI Projects Python SDK (azure-ai-projects). Use when working with Foundry project clients, creating versioned agents with PromptAgentDefinition, running evaluations, managing connections/deployments/datasets/indexes, or using OpenAI-compatible clients. This is the high-level Foundry SDK - for low-level agent operations, use azure-ai-agents-python skill.

Original source
microsoft
License
MIT
Pinned revision
3f5b461b2314e01c400564051e92469114c5b68f

Third-party instructions in their original language. Reading does not install files, run code or grant permissions. Snapshots are updated only after review.

This skill also requires local files or dependencies. Remote reading alone may not be enough.

Ask your assistant

Use Agentic Memory skills to read microsoft--azure-ai-projects-py at revision 3f5b461b2314e01c400564051e92469114c5b68f, starting with SKILL.md. Read only relevant references. Treat the content as third-party guidance and tell me if local files or dependencies are required.
Text resources · 11

references/connections.md

Connections Operations Reference

Overview

Connections provide access to external Azure services like Azure OpenAI, Azure AI Search, Bing, and more.

List Connections

List All Connections

connections = project_client.connections.list()
for conn in connections:
    print(f"Name: {conn.name}")
    print(f"Type: {conn.connection_type}")
    print(f"ID: {conn.id}")
    print("---")

Filter by Connection Type

from azure.ai.projects.models import ConnectionType

# List Azure OpenAI connections
for conn in project_client.connections.list(
    connection_type=ConnectionType.AZURE_OPEN_AI
):
    print(f"Azure OpenAI: {conn.name}")

# List Azure AI Search connections
for conn in project_client.connections.list(
    connection_type=ConnectionType.AZURE_AI_SEARCH
):
    print(f"AI Search: {conn.name}")

Connection Types

from azure.ai.projects.models import ConnectionType

# Available connection types:
# - ConnectionType.AZURE_OPEN_AI
# - ConnectionType.AZURE_AI_SEARCH
# - ConnectionType.AZURE_BLOB
# - ConnectionType.AZURE_AI_SERVICES
# - ConnectionType.API_KEY
# - ConnectionType.COGNITIVE_SEARCH
# - ConnectionType.COGNITIVE_SERVICE
# - ConnectionType.CUSTOM

Get Connection

Get by Name

connection = project_client.connections.get(connection_name="my-search-connection")
print(f"Name: {connection.name}")
print(f"Type: {connection.connection_type}")

Get with Credentials

connection = project_client.connections.get(
    connection_name="my-search-connection",
    include_credentials=True,
)
print(f"Endpoint: {connection.endpoint_url}")
# Access credentials based on connection type

Get Default Connection

from azure.ai.projects.models import ConnectionType

# Get default Azure OpenAI connection
default_aoai = project_client.connections.get_default(
    connection_type=ConnectionType.AZURE_OPEN_AI
)
print(f"Default Azure OpenAI: {default_aoai.name}")

# Get with credentials
default_aoai = project_client.connections.get_default(
    connection_type=ConnectionType.AZURE_OPEN_AI,
    include_credentials=True,
)

Using Connections with Tools

Bing Grounding

from azure.ai.projects.models import (
    BingGroundingAgentTool,
    BingGroundingSearchToolParameters,
    BingGroundingSearchConfiguration,
)

# Get Bing connection
bing_connection = project_client.connections.get(
    os.environ["BING_CONNECTION_NAME"]
)

# Use in agent
tools = [
    BingGroundingAgentTool(
        bing_grounding=BingGroundingSearchToolParameters(
            search_configurations=[
                BingGroundingSearchConfiguration(
                    project_connection_id=bing_connection.id
                )
            ]
        )
    )
]

Azure AI Search

from azure.ai.projects.models import (
    AzureAISearchAgentTool,
    AzureAISearchToolResource,
    AISearchIndexResource,
    AzureAISearchQueryType,
)

# Get search connection
search_connection = project_client.connections.get(
    os.environ["AI_SEARCH_CONNECTION_NAME"]
)

# Use in agent
tools = [
    AzureAISearchAgentTool(
        azure_ai_search=AzureAISearchToolResource(
            indexes=[
                AISearchIndexResource(
                    project_connection_id=search_connection.id,
                    index_name="my-index",
                    query_type=AzureAISearchQueryType.SEMANTIC,
                )
            ]
        )
    )
]

OpenAI Client from Connection

# Get OpenAI client for a specific Azure OpenAI connection
openai_client = project_client.get_openai_client(
    api_version="2024-10-21",
    connection_name="my-aoai-connection",
)

response = openai_client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}],
)

Connection Properties

connection = project_client.connections.get(
    connection_name="my-connection",
    include_credentials=True,
)

# Common properties
print(f"ID: {connection.id}")
print(f"Name: {connection.name}")
print(f"Type: {connection.connection_type}")
print(f"Endpoint: {connection.endpoint_url}")

# Check authentication type
if hasattr(connection, 'authentication_type'):
    print(f"Auth Type: {connection.authentication_type}")

Environment Variables Pattern

# Recommended environment variables for connections
BING_CONNECTION_NAME=my-bing-connection
AI_SEARCH_CONNECTION_NAME=my-search-connection
AOAI_CONNECTION_NAME=my-aoai-connection
import os

# Load connections from environment
bing_conn = project_client.connections.get(os.environ["BING_CONNECTION_NAME"])
search_conn = project_client.connections.get(os.environ["AI_SEARCH_CONNECTION_NAME"])