All skills
microsoft avatar

/azure-ai-projects-py

@4a2873f
by microsoftmicrosoft/skills3.1k stars
351

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.

Use this Skill: https://skilld.dev/gh/microsoft/skills/azure-ai-projects-py

This session only. Nothing lands on disk.

referencesdeployments.md

≈893 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Deployments Operations Reference

Overview

Deployments represent AI model deployments in your Azure AI Foundry project.

List Deployments

List All Deployments

deployments = project_client.deployments.list()
for deployment in deployments:
    print(f"Name: {deployment.name}")
    print(f"Model: {deployment.model_name}")
    print(f"Publisher: {deployment.model_publisher}")
    print("---")

Filter by Publisher

# List only OpenAI model deployments
for deployment in project_client.deployments.list(model_publisher="OpenAI"):
    print(f"{deployment.name}: {deployment.model_name}")

Filter by Model Name

# List deployments of a specific model
for deployment in project_client.deployments.list(model_name="gpt-4o"):
    print(f"{deployment.name}: {deployment.model_version}")

Get Deployment

from azure.ai.projects.models import ModelDeployment

deployment = project_client.deployments.get("my-deployment-name")

if isinstance(deployment, ModelDeployment):
    print(f"Type: {deployment.type}")
    print(f"Name: {deployment.name}")
    print(f"Model Name: {deployment.model_name}")
    print(f"Model Version: {deployment.model_version}")
    print(f"Model Publisher: {deployment.model_publisher}")
    print(f"Capabilities: {deployment.capabilities}")

Deployment Properties

deployment = project_client.deployments.get("gpt-4o-mini")

# Available properties
print(f"Name: {deployment.name}")           # Deployment name
print(f"Model: {deployment.model_name}")    # e.g., "gpt-4o-mini"
print(f"Version: {deployment.model_version}")  # e.g., "2024-07-18"
print(f"Publisher: {deployment.model_publisher}")  # e.g., "OpenAI"
print(f"Type: {deployment.type}")           # Deployment type
print(f"Capabilities: {deployment.capabilities}")  # Model capabilities

Using Deployments

Dynamic Model Selection

# Find available GPT-4 deployments
gpt4_deployments = [
    d for d in project_client.deployments.list()
    if "gpt-4" in d.model_name.lower()
]

if gpt4_deployments:
    deployment_name = gpt4_deployments[0].name
    
    agent = project_client.agents.create_agent(
        model=deployment_name,
        name="dynamic-agent",
        instructions="You are helpful.",
    )

Capability Checking

deployment = project_client.deployments.get("my-deployment")

# Check if deployment supports certain capabilities
if deployment.capabilities:
    supports_vision = deployment.capabilities.get("vision", False)
    supports_functions = deployment.capabilities.get("function_calling", False)
    
    print(f"Vision: {supports_vision}")
    print(f"Function Calling: {supports_functions}")

Environment Variables Pattern

# Store deployment name in environment
AZURE_AI_MODEL_DEPLOYMENT_NAME=gpt-4o-mini
import os

# Use deployment from environment
agent = project_client.agents.create_agent(
    model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
    name="my-agent",
    instructions="You are helpful.",
)

List Available Models

# Print all available models grouped by publisher
from collections import defaultdict

deployments_by_publisher = defaultdict(list)

for deployment in project_client.deployments.list():
    deployments_by_publisher[deployment.model_publisher].append(deployment)

for publisher, deployments in deployments_by_publisher.items():
    print(f"\n{publisher}:")
    for d in deployments:
        print(f"  - {d.name} ({d.model_name} v{d.model_version})")

Source: SKILL.md on GitHub

1 warning16d4 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    This skill provides a comprehensive set of examples, reference implementations, and utility scripts for developing applications using the Azure AI Projects Python SDK. The code follows secure practices, such as prioritizing Entra ID token-based authentication (`DefaultAzureCredential`) over raw API keys, and managing credentials securely via standard environment configurations.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer7mo

    13/13 files flagged

Signed by skilld at 4a2873f. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 20 hours ago.

Activeupdated 2 months ago
Other metadata
metadata
{
  "author": "Microsoft",
  "version": "1.0.0",
  "package": "azure-ai-projects"
}

README badge

README badge for microsoft/skills/azure-ai-projects-py