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.
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.
- 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
# 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-dotenvCreate 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) |
python deployments_async.pyExample 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
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.envfile to source control. Add it to.gitignoreto avoid exposing credentials.
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)This project is provided as-is for demonstration and learning purposes.