Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MSFoundryDeploymentList

A Python utility to list and inspect model deployments in Azure AI Foundry (formerly Azure AI Studio) using the Azure AI Projects SDK with async support.


Overview

This script connects to an Azure AI Foundry project and demonstrates how to:

  • List all model deployments in a project
  • Filter deployments by model publisher (e.g. Microsoft)
  • Filter deployments by model name (e.g. Phi-4)
  • Fetch a single deployment by name and inspect its properties (type, version, capabilities, SKU, connection name)

It uses asyncio for non-blocking API calls and DefaultAzureCredential for seamless Azure authentication.


Prerequisites

  • Python 3.9+
  • An Azure AI Foundry project with at least one model deployment
  • Azure CLI installed and authenticated (az login), or another supported credential method

Installation

# Clone the repository
git clone https://github.com/praveen11singh/MSFoundryDeploymentList.git
cd MSFoundryDeploymentList

# Create and activate a virtual environment (optional but recommended)
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
pip install azure-ai-projects azure-identity python-dotenv

Configuration

Create a .env file in the project root (one is already included — fill in your values):

# Required
FOUNDRY_PROJECT_ENDPOINT=https://<your-project>.services.ai.azure.com/api/projects/<project-id>
FOUNDRY_MODEL_NAME=<your-deployment-name>

# Optional (defaults shown)
MODEL_PUBLISHER=Microsoft
MODEL_NAME=Phi-4
Variable Description Required
FOUNDRY_PROJECT_ENDPOINT Your Azure AI Foundry project endpoint URL
FOUNDRY_MODEL_NAME Name of a specific deployment to fetch
MODEL_PUBLISHER Publisher to filter by when listing ❌ (default: Microsoft)
MODEL_NAME Model name to filter by when listing ❌ (default: Phi-4)

Usage

python deployments_async.py

Example output:

List all deployments:
ModelDeployment(name='gpt-4o', ...)
ModelDeployment(name='Phi-4', ...)

List all deployments by the model publisher `Microsoft`:
ModelDeployment(name='Phi-4', ...)

List all deployments of model `Phi-4`:
ModelDeployment(name='Phi-4', ...)

Get a single deployment named `Phi-4`:
Type: ModelDeployment
Name: Phi-4
Model Name: Phi-4
Model Version: 4.0
Model Publisher: Microsoft
Capabilities: {'chat': True, 'completion': True}
SKU: Standard
Connection Name: my-connection

Project Structure

MSFoundryDeploymentList/
├── deployments_async.py   # Main async script
├── .env                   # Environment variables (not committed — add to .gitignore)
└── .pkvenv/               # Virtual environment (if created locally)

⚠��� Important: Never commit your .env file to source control. Add it to .gitignore to avoid exposing credentials.


How It Works

The script uses the AIProjectClient from azure-ai-projects to interact with the Foundry REST API. Authentication is handled by DefaultAzureCredential, which automatically picks up credentials from the Azure CLI, environment variables, managed identity, and more.

async with (
    DefaultAzureCredential() as credential,
    AIProjectClient(endpoint=endpoint, credential=credential) as project_client,
):
    async for deployment in project_client.deployments.list():
        print(deployment)

Related Resources


License

This project is provided as-is for demonstration and learning purposes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages