microsoft-foundry
Use this skill to work with Microsoft Foundry (Azure AI Foundry): deploy AI models from catalog, build RAG applications with knowledge indexes, create and evaluate AI agents, manage RBAC permissions and role assignments, manage quotas and capacity, create Foundry resources. USE FOR: Microsoft Foundry, AI Foundry, deploy model, model catalog, RAG, knowledge index, create agent, evaluate agent, agent monitoring, create Foundry project, new Foundry project, set up Foundry, onboard to Foundry, provision Foundry infrastructure, create Foundry resource, create AI Services, multi-service resource, AIServices kind, register resource provider, enable Cognitive Services, setup AI Services account, create resource group for Foundry, RBAC, role assignment, managed identity, service principal, permissions, quota, capacity, TPM, deployment failure, QuotaExceeded. DO NOT USE FOR: Azure Functions (use azure-functions), App Service (use azure-create-app), generic Azure resource creation (use azure-create-app).
Packaged view
This page reorganizes the original catalog entry around fit, installability, and workflow context first. The original raw source lives below.
Install command
npx @skill-hub/cli install microsoft-skills-microsoft-foundry
Repository
Skill path: .github/plugins/azure-skills/skills/microsoft-foundry
Use this skill to work with Microsoft Foundry (Azure AI Foundry): deploy AI models from catalog, build RAG applications with knowledge indexes, create and evaluate AI agents, manage RBAC permissions and role assignments, manage quotas and capacity, create Foundry resources. USE FOR: Microsoft Foundry, AI Foundry, deploy model, model catalog, RAG, knowledge index, create agent, evaluate agent, agent monitoring, create Foundry project, new Foundry project, set up Foundry, onboard to Foundry, provision Foundry infrastructure, create Foundry resource, create AI Services, multi-service resource, AIServices kind, register resource provider, enable Cognitive Services, setup AI Services account, create resource group for Foundry, RBAC, role assignment, managed identity, service principal, permissions, quota, capacity, TPM, deployment failure, QuotaExceeded. DO NOT USE FOR: Azure Functions (use azure-functions), App Service (use azure-create-app), generic Azure resource creation (use azure-create-app).
Open repositoryBest for
Primary workflow: Analyze Data & AI.
Technical facets: Full Stack, DevOps, Data / AI.
Target audience: everyone.
License: Unknown.
Original source
Catalog source: SkillHub Club.
Repository owner: microsoft.
This is still a mirrored public skill entry. Review the repository before installing into production workflows.
What it helps with
- Install microsoft-foundry into Claude Code, Codex CLI, Gemini CLI, or OpenCode workflows
- Review https://github.com/microsoft/skills before adding microsoft-foundry to shared team environments
- Use microsoft-foundry for development workflows
Works across
Favorites: 0.
Sub-skills: 0.
Aggregator: No.
Original source / Raw SKILL.md
---
name: microsoft-foundry
description: |
Use this skill to work with Microsoft Foundry (Azure AI Foundry): deploy AI models from catalog, build RAG applications with knowledge indexes, create and evaluate AI agents, manage RBAC permissions and role assignments, manage quotas and capacity, create Foundry resources.
USE FOR: Microsoft Foundry, AI Foundry, deploy model, model catalog, RAG, knowledge index, create agent, evaluate agent, agent monitoring, create Foundry project, new Foundry project, set up Foundry, onboard to Foundry, provision Foundry infrastructure, create Foundry resource, create AI Services, multi-service resource, AIServices kind, register resource provider, enable Cognitive Services, setup AI Services account, create resource group for Foundry, RBAC, role assignment, managed identity, service principal, permissions, quota, capacity, TPM, deployment failure, QuotaExceeded.
DO NOT USE FOR: Azure Functions (use azure-functions), App Service (use azure-create-app), generic Azure resource creation (use azure-create-app).
---
# Microsoft Foundry Skill
This skill helps developers work with Microsoft Foundry resources, covering model discovery and deployment, RAG (Retrieval-Augmented Generation) applications, AI agent creation, evaluation workflows, and troubleshooting.
## Sub-Skills
This skill includes specialized sub-skills for specific workflows. **Use these instead of the main skill when they match your task:**
| Sub-Skill | When to Use | Reference |
|-----------|-------------|-----------|
| **project/create** | Creating a new Azure AI Foundry project for hosting agents and models. Use when onboarding to Foundry or setting up new infrastructure. | [project/create/create-foundry-project.md](project/create/create-foundry-project.md) |
| **resource/create** | Creating Azure AI Services multi-service resource (Foundry resource) using Azure CLI. Use when manually provisioning AI Services resources with granular control. | [resource/create/create-foundry-resource.md](resource/create/create-foundry-resource.md) |
| **models/deploy-model** | Unified model deployment with intelligent routing. Handles quick preset deployments, fully customized deployments (version/SKU/capacity/RAI), and capacity discovery across regions. Routes to sub-skills: `preset` (quick deploy), `customize` (full control), `capacity` (find availability). | [models/deploy-model/SKILL.md](models/deploy-model/SKILL.md) |
| **agent/create/agent-framework** | Creating AI agents and workflows using Microsoft Agent Framework SDK. Supports single-agent and multi-agent workflow patterns with HTTP server and F5/debug support. | [agent/create/agent-framework/SKILL.md](agent/create/agent-framework/SKILL.md) |
| **quota** | Managing quotas and capacity for Microsoft Foundry resources. Use when checking quota usage, troubleshooting deployment failures due to insufficient quota, requesting quota increases, or planning capacity. | [quota/quota.md](quota/quota.md) |
| **rbac** | Managing RBAC permissions, role assignments, managed identities, and service principals for Microsoft Foundry resources. Use for access control, auditing permissions, and CI/CD setup. | [rbac/rbac.md](rbac/rbac.md) |
> ๐ก **Tip:** For a complete onboarding flow: `project/create` โ `agent/create` โ `agent/deploy`. If the user wants to **create AND deploy** an agent, start with `agent/create` which can optionally invoke `agent/deploy` automatically.
> ๐ก **Model Deployment:** Use `models/deploy-model` for all deployment scenarios โ it intelligently routes between quick preset deployment, customized deployment with full control, and capacity discovery across regions.
## SDK Quick Reference
- [Python](references/sdk/foundry-sdk-py.md)
---
## Referenced Files
> The following files are referenced in this skill and included for context.
### project/create/create-foundry-project.md
```markdown
---
name: foundry-create-project
description: |
Create a new Azure AI Foundry project using Azure Developer CLI (azd) to provision infrastructure for hosting AI agents and models.
USE FOR: create Foundry project, new AI Foundry project, set up Foundry, azd init Foundry, provision Foundry infrastructure, onboard to Foundry, create Azure AI project, set up AI project.
DO NOT USE FOR: deploying agents to existing projects (use agent/deploy), creating agent code (use agent/create), deploying AI models from catalog (use microsoft-foundry main skill), Azure Functions (use azure-functions).
allowed-tools: Read, Write, Bash, AskUserQuestion
---
# Create Azure AI Foundry Project
Create a new Azure AI Foundry project using azd. Provisions: Foundry account, project, Container Registry, Application Insights, managed identity, and RBAC permissions.
## Prerequisites
Run checks in order. STOP on any failure and resolve before proceeding.
**1. Azure CLI** โ `az version` โ expects version output. If missing: https://aka.ms/installazurecli
**2. Azure login & subscription:**
```bash
az account show --query "{Name:name, SubscriptionId:id, State:state}" -o table
```
If not logged in, run `az login`. If no active subscription: https://azure.microsoft.com/free/ โ STOP.
If multiple subscriptions, ask which to use, then `az account set --subscription "<id>"`.
**3. Role permissions:**
```bash
az role assignment list --assignee "$(az ad signed-in-user show --query id -o tsv)" --query "[?contains(roleDefinitionName, 'Owner') || contains(roleDefinitionName, 'Contributor') || contains(roleDefinitionName, 'Azure AI')].{Role:roleDefinitionName, Scope:scope}" -o table
```
Requires Owner, Contributor, or Azure AI Owner. If insufficient โ STOP, request elevated access from admin.
**4. Azure Developer CLI** โ `azd version`. If missing: https://aka.ms/azure-dev/install
## Workflow
### Step 1: Verify azd login
```bash
azd auth login --check-status
```
If not logged in, run `azd auth login` and complete browser auth.
### Step 2: Ask User for Project Details
Use AskUserQuestion for:
1. **Project name** โ used as azd environment name and resource group (`rg-<name>`). Must contain only alphanumeric characters and hyphens. Examples: `my-ai-project`, `dev-agents`
2. **Azure location** (optional) โ defaults to North Central US (required for hosted agents preview)
### Step 3: Create Directory and Initialize
```bash
mkdir "<project-name>" && cd "<project-name>"
azd init -t https://github.com/Azure-Samples/azd-ai-starter-basic -e <project-name> --no-prompt
```
- `-t` โ Azure AI starter template (Foundry infrastructure)
- `-e` โ environment name
- `--no-prompt` โ non-interactive, use defaults
- **IMPORTANT:** `azd init` requires an empty directory
If user specified a non-default location:
```bash
azd config set defaults.location <location>
```
### Step 4: Provision Infrastructure
```bash
azd provision --no-prompt
```
Takes 5โ10 minutes. Creates resource group, Foundry account/project, Container Registry, Application Insights, managed identity, and RBAC roles.
### Step 5: Retrieve Project Details
```bash
azd env get-values
```
Capture `AZURE_AI_PROJECT_ID`, `AZURE_AI_PROJECT_ENDPOINT`, and `AZURE_RESOURCE_GROUP`. Direct user to verify at https://ai.azure.com.
### Step 6: Next Steps
- Deploy an agent โ `agent/deploy` skill
- Browse models โ `foundry_models_list` MCP tool
- Manage project โ https://ai.azure.com
## Best Practices
- Use North Central US for hosted agents (preview requirement)
- Name must be alphanumeric + hyphens only โ no spaces, underscores, or special characters
- Delete unused projects with `azd down` to avoid ongoing costs
- `azd down` deletes ALL resources โ Foundry account, agents, models, Container Registry, and Application Insights data
- `azd provision` is safe to re-run on failure
## Troubleshooting
| Problem | Solution |
|---------|----------|
| `azd: command not found` | Install from https://aka.ms/azure-dev/install |
| `ERROR: Failed to authenticate` | Run `azd auth login`; verify subscription with `az account list` |
| `environment name '' is invalid` | Name must be alphanumeric + hyphens only |
| `ERROR: Insufficient permissions` | Request Contributor or Azure AI Owner role from admin |
| Region not supported for hosted agents | Use `azd config set defaults.location northcentralus` |
| Provisioning timeout | Check region availability, verify connectivity, retry `azd provision` |
## Related Skills
- **agent/deploy** โ Deploy agents to the created project
- **agent/create** โ Create a new agent for deployment
## Resources
- [Azure Developer CLI](https://aka.ms/azure-dev/install) ยท [AI Foundry Portal](https://ai.azure.com) ยท [Foundry Docs](https://learn.microsoft.com/azure/ai-foundry/) ยท [azd-ai-starter-basic template](https://github.com/Azure-Samples/azd-ai-starter-basic)
```
### resource/create/create-foundry-resource.md
```markdown
---
name: microsoft-foundry:resource/create
description: |
Create Azure AI Services multi-service resource (Foundry resource) using Azure CLI.
USE FOR: create Foundry resource, new AI Services resource, create multi-service resource, provision Azure AI Services, AIServices kind resource, register resource provider, enable Cognitive Services, setup AI Services account, create resource group for Foundry.
DO NOT USE FOR: creating ML workspace hubs (use microsoft-foundry:project/create), deploying models (use microsoft-foundry:models/deploy), managing permissions (use microsoft-foundry:rbac), monitoring resource usage (use microsoft-foundry:quota).
compatibility:
required:
- azure-cli: ">=2.0"
optional:
- powershell: ">=7.0"
- azure-portal: "any"
---
# Create Foundry Resource
This sub-skill orchestrates creation of Azure AI Services multi-service resources using Azure CLI.
> **Important:** All resource creation operations are **control plane (management)** operations. Use **Azure CLI commands** as the primary method.
> **Note:** For monitoring resource usage and quotas, use the `microsoft-foundry:quota` skill.
## Quick Reference
| Property | Value |
|----------|-------|
| **Classification** | WORKFLOW SKILL |
| **Operation Type** | Control Plane (Management) |
| **Primary Method** | Azure CLI: `az cognitiveservices account create` |
| **Resource Type** | `Microsoft.CognitiveServices/accounts` (kind: `AIServices`) |
| **Resource Kind** | `AIServices` (multi-service) |
## When to Use
Use this sub-skill when you need to:
- **Create Foundry resource** - Provision new Azure AI Services multi-service account
- **Create resource group** - Set up resource group before creating resources
- **Register resource provider** - Enable Microsoft.CognitiveServices provider
- **Manual resource creation** - CLI-based resource provisioning
**Do NOT use for:**
- Creating ML workspace hubs/projects (use `microsoft-foundry:project/create`)
- Deploying AI models (use `microsoft-foundry:models/deploy`)
- Managing RBAC permissions (use `microsoft-foundry:rbac`)
- Monitoring resource usage (use `microsoft-foundry:quota`)
## Prerequisites
- **Azure subscription** - Active subscription ([create free account](https://azure.microsoft.com/pricing/purchase-options/azure-account))
- **Azure CLI** - Version 2.0 or later installed
- **Authentication** - Run `az login` before commands
- **RBAC roles** - One of:
- Contributor
- Owner
- Custom role with `Microsoft.CognitiveServices/accounts/write`
- **Resource provider** - `Microsoft.CognitiveServices` must be registered in your subscription
- If not registered, see [Workflow #3: Register Resource Provider](#3-register-resource-provider)
- If you lack permissions, ask a subscription Owner/Contributor to register it or grant you `/register/action` privilege
> **Need RBAC help?** See [microsoft-foundry:rbac](../../rbac/rbac.md) for permission management.
## Core Workflows
### 1. Create Resource Group
**Command Pattern:** "Create a resource group for my Foundry resources"
#### Steps
1. **Ask user preference**: Use existing or create new resource group
2. **If using existing**: List and let user select from available groups (0-4: show all, 5+: show 5 most recent with "Other" option)
3. **If creating new**: Ask user to choose region, then create
```bash
# List existing resource groups
az group list --query "[-5:].{Name:name, Location:location}" --out table
# Or create new
az group create --name <rg-name> --location <location>
az group show --name <rg-name> --query "{Name:name, Location:location, State:properties.provisioningState}"
```
See [Detailed Workflow Steps](./references/workflows.md) for complete instructions.
---
### 2. Create Foundry Resource
**Command Pattern:** "Create a new Azure AI Services resource"
#### Steps
1. **Verify prerequisites**: Check Azure CLI, authentication, and provider registration
2. **Choose location**: Always ask user to select region (don't assume resource group location)
3. **Create resource**: Use `--kind AIServices` and `--sku S0` (only supported tier)
4. **Verify and get keys**
```bash
# Create Foundry resource
az cognitiveservices account create \
--name <resource-name> \
--resource-group <rg> \
--kind AIServices \
--sku S0 \
--location <location> \
--yes
# Verify and get keys
az cognitiveservices account show --name <resource-name> --resource-group <rg>
az cognitiveservices account keys list --name <resource-name> --resource-group <rg>
```
**Important:** S0 (Standard) is the only supported SKU - F0 free tier not available for AIServices.
See [Detailed Workflow Steps](./references/workflows.md) for complete instructions.
---
### 3. Register Resource Provider
**Command Pattern:** "Register Cognitive Services provider"
Required when first creating Cognitive Services in subscription or if you get `ResourceProviderNotRegistered` error.
```bash
# Register provider (requires Owner/Contributor role)
az provider register --namespace Microsoft.CognitiveServices
az provider show --namespace Microsoft.CognitiveServices --query "registrationState"
```
If you lack permissions, ask a subscription Owner/Contributor to register it or use `microsoft-foundry:rbac` skill.
See [Detailed Workflow Steps](./references/workflows.md) for complete instructions.
---
## Important Notes
- **Resource kind must be `AIServices`** for multi-service Foundry resources
- **SKU must be S0** (Standard) - F0 free tier not available for AIServices
- Always ask user to choose location - different regions may have varying availability
---
## Additional Resources
- [Common Patterns](./references/patterns.md) - Quick setup patterns and command reference
- [Troubleshooting](./references/troubleshooting.md) - Common errors and solutions
- [Azure AI Services documentation](https://learn.microsoft.com/en-us/azure/ai-services/multi-service-resource?pivots=azcli)
```
### models/deploy-model/SKILL.md
```markdown
---
name: deploy-model
description: |
Unified Azure OpenAI model deployment skill with intelligent intent-based routing. Handles quick preset deployments, fully customized deployments (version/SKU/capacity/RAI policy), and capacity discovery across regions and projects.
USE FOR: deploy model, deploy gpt, create deployment, model deployment, deploy openai model, set up model, provision model, find capacity, check model availability, where can I deploy, best region for model, capacity analysis.
DO NOT USE FOR: listing existing deployments (use foundry_models_deployments_list MCP tool), deleting deployments, agent creation (use agent/create), project creation (use project/create).
---
# Deploy Model
Unified entry point for all Azure OpenAI model deployment workflows. Analyzes user intent and routes to the appropriate deployment mode.
## Quick Reference
| Mode | When to Use | Sub-Skill |
|------|-------------|-----------|
| **Preset** | Quick deployment, no customization needed | [preset/SKILL.md](preset/SKILL.md) |
| **Customize** | Full control: version, SKU, capacity, RAI policy | [customize/SKILL.md](customize/SKILL.md) |
| **Capacity Discovery** | Find where you can deploy with specific capacity | [capacity/SKILL.md](capacity/SKILL.md) |
## Intent Detection
Analyze the user's prompt and route to the correct mode:
```
User Prompt
โ
โโ Simple deployment (no modifiers)
โ "deploy gpt-4o", "set up a model"
โ โโ> PRESET mode
โ
โโ Customization keywords present
โ "custom settings", "choose version", "select SKU",
โ "set capacity to X", "configure content filter",
โ "PTU deployment", "with specific quota"
โ โโ> CUSTOMIZE mode
โ
โโ Capacity/availability query
โ "find where I can deploy", "check capacity",
โ "which region has X capacity", "best region for 10K TPM",
โ "where is this model available"
โ โโ> CAPACITY DISCOVERY mode
โ
โโ Ambiguous (has capacity target + deploy intent)
"deploy gpt-4o with 10K capacity to best region"
โโ> CAPACITY DISCOVERY first โ then PRESET or CUSTOMIZE
```
### Routing Rules
| Signal in Prompt | Route To | Reason |
|------------------|----------|--------|
| Just model name, no options | **Preset** | User wants quick deployment |
| "custom", "configure", "choose", "select" | **Customize** | User wants control |
| "find", "check", "where", "which region", "available" | **Capacity** | User wants discovery |
| Specific capacity number + "best region" | **Capacity โ Preset** | Discover then deploy quickly |
| Specific capacity number + "custom" keywords | **Capacity โ Customize** | Discover then deploy with options |
| "PTU", "provisioned throughput" | **Customize** | PTU requires SKU selection |
| "optimal region", "best region" (no capacity target) | **Preset** | Region optimization is preset's specialty |
### Multi-Mode Chaining
Some prompts require two modes in sequence:
**Pattern: Capacity โ Deploy**
When a user specifies a capacity requirement AND wants deployment:
1. Run **Capacity Discovery** to find regions/projects with sufficient quota
2. Present findings to user
3. Ask: "Would you like to deploy with **quick defaults** or **customize settings**?"
4. Route to **Preset** or **Customize** based on answer
> ๐ก **Tip:** If unsure which mode the user wants, default to **Preset** (quick deployment). Users who want customization will typically use explicit keywords like "custom", "configure", or "with specific settings".
## Project Selection (All Modes)
Before any deployment, resolve which project to deploy to. This applies to **all** modes (preset, customize, and after capacity discovery).
### Resolution Order
1. **Check `PROJECT_RESOURCE_ID` env var** โ if set, use it as the default
2. **Check user prompt** โ if user named a specific project or region, use that
3. **If neither** โ query the user's projects and suggest the current one
### Confirmation Step (Required)
**Always confirm the target before deploying.** Show the user what will be used and give them a chance to change it:
```
Deploying to:
Project: <project-name>
Region: <region>
Resource: <resource-group>
Is this correct? Or choose a different project:
1. โ
Yes, deploy here (default)
2. ๐ Show me other projects in this region
3. ๐ Choose a different region
```
If user picks option 2, show top 5 projects in that region:
```
Projects in <region>:
1. project-alpha (rg-alpha)
2. project-beta (rg-beta)
3. project-gamma (rg-gamma)
...
```
> โ ๏ธ **Never deploy without showing the user which project will be used.** This prevents accidental deployments to the wrong resource.
## Pre-Deployment Validation (All Modes)
Before presenting any deployment options (SKU, capacity), always validate both of these:
1. **Model supports the SKU** โ query the model catalog to confirm the selected model+version supports the target SKU:
```bash
az cognitiveservices model list --location <region> --subscription <sub-id> -o json
```
Filter for the model, extract `.model.skus[].name` to get supported SKUs.
2. **Subscription has available quota** โ check that the user's subscription has unallocated quota for the SKU+model combination:
```bash
az cognitiveservices usage list --location <region> --subscription <sub-id> -o json
```
Match by usage name pattern `OpenAI.<SKU>.<model-name>` (e.g., `OpenAI.GlobalStandard.gpt-4o`). Compute `available = limit - currentValue`.
> โ ๏ธ **Warning:** Only present options that pass both checks. Do NOT show hardcoded SKU lists โ always query dynamically. SKUs with 0 available quota should be shown as โ informational items, not selectable options.
> ๐ก **Quota management:** For quota increase requests, usage monitoring, and troubleshooting quota errors, defer to the [quota skill](../../quota/quota.md) instead of duplicating that guidance inline.
## Prerequisites
All deployment modes require:
- Azure CLI installed and authenticated (`az login`)
- Active Azure subscription with deployment permissions
- Azure AI Foundry project resource ID (or agent will help discover it via `PROJECT_RESOURCE_ID` env var)
## Sub-Skills
- **[preset/SKILL.md](preset/SKILL.md)** โ Quick deployment to optimal region with sensible defaults
- **[customize/SKILL.md](customize/SKILL.md)** โ Interactive guided flow with full configuration control
- **[capacity/SKILL.md](capacity/SKILL.md)** โ Discover available capacity across regions and projects
```
### agent/create/agent-framework/SKILL.md
```markdown
---
name: agent-framework
description: |
Create AI agents and workflows using Microsoft Agent Framework SDK. Supports single-agent and multi-agent workflow patterns.
USE FOR: create agent, build agent, scaffold agent, new agent, agent framework, workflow pattern, multi-agent, MCP tools, create workflow.
DO NOT USE FOR: deploying agents (use agent/deploy), evaluating agents (use agent/evaluate), Azure AI Foundry agents without Agent Framework SDK.
---
# Create Agent with Microsoft Agent Framework
Build AI agents, agentic apps, and multi-agent workflows using Microsoft Agent Framework SDK.
## Quick Reference
| Property | Value |
|----------|-------|
| **SDK** | Microsoft Agent Framework (Python) |
| **Patterns** | Single Agent, Multi-Agent Workflow |
| **Server** | Azure AI Agent Server SDK (HTTP) |
| **Debug** | AI Toolkit Agent Inspector + VSCode |
| **Best For** | Enterprise agents with type safety, checkpointing, orchestration |
## When to Use This Skill
Use when the user wants to:
- **Create** a new AI agent or agentic application
- **Scaffold** an agent with tools (MCP, function calling)
- **Build** multi-agent workflows with orchestration patterns
- **Add** HTTP server mode to an existing agent
- **Configure** F5/debug support for VSCode
## Defaults
- **Language**: Python
- **SDK**: Microsoft Agent Framework (pin version `1.0.0b260107`)
- **Server**: HTTP via Azure AI Agent Server SDK
- **Environment**: Virtual environment (create or detect existing)
## References
| Topic | File | Description |
|-------|------|-------------|
| Server Pattern | [references/agent-as-server.md](references/agent-as-server.md) | HTTP server wrapping (production) |
| Debug Setup | [references/debug-setup.md](references/debug-setup.md) | VS Code configs for Agent Inspector |
| Agent Samples | [references/agent-samples.md](references/agent-samples.md) | Single agent, tools, MCP, threads |
| Workflow Basics | [references/workflow-basics.md](references/workflow-basics.md) | Executor types, handler signatures, edges, WorkflowBuilder โ start here for any workflow |
| Workflow Agents | [references/workflow-agents.md](references/workflow-agents.md) | Agents as executor nodes, linear pipeline, run_stream event consumption |
| Workflow Foundry | [references/workflow-foundry.md](references/workflow-foundry.md) | Foundry agents with bidirectional edges, loop control, register_executor factories |
> ๐ก **Tip:** For advanced patterns (Reflection, Switch-Case, Fan-out/Fan-in, Loop, Human-in-Loop), search `microsoft/agent-framework` on GitHub.
## MCP Tools
This skill delegates to `microsoft-foundry` MCP tools for model and project operations:
| Tool | Purpose |
|------|---------|
| `foundry_models_list` | Browse model catalog for selection |
| `foundry_models_deployments_list` | List deployed models for selection |
| `foundry_resource_get` | Get project endpoint |
## Creation Workflow
1. Gather context (read agent-as-server.md + debug-setup.md + code samples)
2. Select model & configure environment
3. Implement agent/workflow code + HTTP server mode + `.vscode/` configs
4. Install dependencies (venv + requirements.txt)
5. Verify startup (Run-Fix loop)
6. Documentation
### Step 1: Gather Context
Read reference files based on user's request:
**Always read these references:**
- Server pattern: **agent-as-server.md** (required โ HTTP server is the default)
- Debug setup: **debug-setup.md** (required โ always generate `.vscode/` configs)
**Read the relevant code sample:**
- Code samples: agent-samples.md, workflow-basics.md, workflow-agents.md, or workflow-foundry.md
**Model Selection**: Use `microsoft-foundry` skill's model catalog to help user select and deploy a model.
**Recommended**: Search `microsoft/agent-framework` on GitHub for advanced patterns.
### Step 2: Select Model & Configure Environment
*Decide on the model BEFORE coding.*
If user hasn't specified a model, use `microsoft-foundry` skill to list deployed models or help deploy one.
**ALWAYS create/update `.env` file**:
```bash
FOUNDRY_PROJECT_ENDPOINT=<project-endpoint>
FOUNDRY_MODEL_DEPLOYMENT_NAME=<model-deployment-name>
```
- **Standard flow**: Populate with real values from user's Foundry project
- **Deferred Config**: Use placeholders, remind user to update before running
### Step 3: Implement Code
**All three are required by default:**
1. **Agent/Workflow code**: Use gathered context to structure the agent or workflow
2. **HTTP Server mode**: Wrap with Agent-as-Server pattern from `agent-as-server.md` โ this is the default entry point
3. **Debug configs**: Generate `.vscode/launch.json` and `.vscode/tasks.json` using templates from `debug-setup.md`
> โ ๏ธ **Warning:** Only skip server mode or debug configs if the user explicitly requests a "minimal" or "no server" setup.
### Step 4: Install Dependencies
1. Generate/update `requirements.txt`
```text
# pin version to avoid breaking changes
# agent framework
agent-framework-azure-ai==1.0.0b260107
agent-framework-core==1.0.0b260107
# agent server (for HTTP server mode)
azure-ai-agentserver-core==1.0.0b10
azure-ai-agentserver-agentframework==1.0.0b10
# debugging support
debugpy
agent-dev-cli
```
2. Use a virtual environment to avoid polluting the global Python installation
> โ ๏ธ **Warning:** Never use bare `python` or `pip` โ always use the venv-activated versions or full paths (e.g., `.venv/bin/pip`).
### Step 5: Verify Startup (Run-Fix Loop)
Enter a run-fix loop until no startup errors:
1. Run the main entrypoint using the venv's Python (e.g., `.venv/Scripts/python main.py` on Windows, `.venv/bin/python main.py` on macOS/Linux)
2. **If startup fails**: Fix error โ Rerun
3. **If startup succeeds**: Stop server immediately
**Guardrails**:
- โ
Perform real run to catch startup errors
- โ
Cleanup after verification (stop HTTP server)
- โ
Ignore environment/auth/connection/timeout errors
- โ Don't wait for user input
- โ Don't create separate test scripts
- โ Don't mock configuration
### Step 6: Documentation
Create/update `README.md` with setup instructions and usage examples.
## Error Handling
| Error | Cause | Resolution |
|-------|-------|------------|
| `ModuleNotFoundError` | Missing SDK | Run `pip install agent-framework-azure-ai==1.0.0b260107` in venv |
| `AgentRunResponseUpdate` not found | Wrong SDK version | Pin to `1.0.0b260107` (breaking rename in newer versions) |
| Agent name validation error | Invalid characters | Use alphanumeric + hyphens, start/end with alphanumeric, max 63 chars |
| Async credential error | Wrong import | Use `azure.identity.aio.DefaultAzureCredential` (not `azure.identity`) |
```
### quota/quota.md
```markdown
# Microsoft Foundry Quota Management
Quota and capacity management for Microsoft Foundry. Quotas are **subscription + region** level.
> **Agent Rule:** Query REGIONAL quota summary, NOT individual resources. Don't run `az cognitiveservices account list` for quota queries.
## Quota Types
| Type | Description |
|------|-------------|
| **TPM** | Tokens Per Minute, pay-per-token, subject to rate limits |
| **PTU** | Provisioned Throughput Units, monthly commitment, no rate limits |
| **Region** | Max capacity per region, shared across subscription |
| **Slots** | 10-20 deployment slots per resource |
**When to use PTU:** Consistent high-volume production workloads where monthly commitment is cost-effective.
## Core Workflows
### 1. Check Regional Quota
**Command Pattern:** "Show my Microsoft Foundry quota usage"
```bash
subId=$(az account show --query id -o tsv)
az rest --method get \
--url "https://management.azure.com/subscriptions/$subId/providers/Microsoft.CognitiveServices/locations/eastus/usages?api-version=2023-05-01" \
--query "value[?contains(name.value,'OpenAI')].{Model:name.value, Used:currentValue, Limit:limit}" -o table
```
Change region as needed: `eastus`, `eastus2`, `westus`, `westus2`, `swedencentral`, `uksouth`.
See [Detailed Workflow Steps](./references/workflows.md) for complete instructions including multi-region checks and resource-specific queries.
---
### 2. Find Best Region for Deployment
**Command Pattern:** "Which region has available quota for GPT-4o?"
Check specific regions one at a time:
```bash
subId=$(az account show --query id -o tsv)
region="eastus"
az rest --method get \
--url "https://management.azure.com/subscriptions/$subId/providers/Microsoft.CognitiveServices/locations/$region/usages?api-version=2023-05-01" \
--query "value[?name.value=='OpenAI.Standard.gpt-4o'].{Model:name.value, Used:currentValue, Limit:limit, Available:(limit-currentValue)}" -o table
```
See [Detailed Workflow Steps](./references/workflows.md) for multi-region comparison.
---
### 3. Deploy with PTU
**Command Pattern:** "Deploy GPT-4o with PTU"
Use Foundry Portal capacity calculator first, then deploy:
```bash
az cognitiveservices account deployment create --name <resource> --resource-group <rg> \
--deployment-name gpt-4o-ptu --model-name gpt-4o --model-version "2024-05-13" \
--model-format OpenAI --sku-name ProvisionedManaged --sku-capacity 100
```
See [PTU Guide](./references/ptu-guide.md) for capacity planning and when to use PTU.
---
### 4. Delete Deployment (Free Quota)
**Command Pattern:** "Delete unused deployment to free quota"
```bash
az cognitiveservices account deployment delete --name <resource> --resource-group <rg> \
--deployment-name <deployment>
```
---
## Troubleshooting
| Error | Quick Fix |
|-------|-----------|
| `QuotaExceeded` | Delete unused deployments or request increase |
| `InsufficientQuota` | Reduce capacity or try different region |
| `DeploymentLimitReached` | Delete unused deployments |
| `429 Rate Limit` | Increase TPM or migrate to PTU |
See [Troubleshooting Guide](./references/troubleshooting.md) for detailed error resolution steps.
---
## Request Quota Increase
Azure Portal โ Foundry resource โ **Quotas** โ **Request quota increase**. Include business justification. Processing: 1-2 days.
---
## References
- [Detailed Workflows](./references/workflows.md) - Complete workflow steps and multi-region checks
- [PTU Guide](./references/ptu-guide.md) - Provisioned throughput capacity planning
- [Troubleshooting](./references/troubleshooting.md) - Error resolution and diagnostics
- [Quota Management](https://learn.microsoft.com/azure/ai-services/openai/how-to/quota)
- [Rate Limits](https://learn.microsoft.com/azure/ai-services/openai/quotas-limits)
```
### rbac/rbac.md
```markdown
# Microsoft Foundry RBAC Management
Reference for managing RBAC for Microsoft Foundry resources: user permissions, managed identity configuration, and service principal setup for CI/CD.
## Quick Reference
| Property | Value |
|----------|-------|
| **CLI Extension** | `az role assignment`, `az ad sp` |
| **Resource Type** | `Microsoft.CognitiveServices/accounts` |
| **Best For** | Permission management, access auditing, CI/CD setup |
## When to Use
- Grant user access to Foundry resources or projects
- Set up developer permissions (Project Manager, Owner roles)
- Audit role assignments or validate permissions
- Configure managed identity roles for connected resources
- Create service principals for CI/CD pipeline automation
- Troubleshoot permission errors
## Azure AI Foundry Built-in Roles
| Role | Create Projects | Data Actions | Role Assignments |
|------|-----------------|--------------|------------------|
| Azure AI User | No | Yes | No |
| Azure AI Project Manager | Yes | Yes | Yes (AI User only) |
| Azure AI Account Owner | Yes | No | Yes (AI User only) |
| Azure AI Owner | Yes | Yes | Yes |
> โ ๏ธ **Warning:** Azure AI User is auto-assigned via Portal but NOT via SDK/CLI. Automation must explicitly assign roles.
## Workflows
All scopes follow the pattern: `/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.CognitiveServices/accounts/<foundry-resource-name>`
For project-level scoping, append `/projects/<project-name>`.
### 1. Assign User Permissions
```bash
az role assignment create --role "Azure AI User" --assignee "<user-email-or-object-id>" --scope "<foundry-scope>"
```
### 2. Assign Developer Permissions
```bash
# Project Manager (create projects, assign AI User roles)
az role assignment create --role "Azure AI Project Manager" --assignee "<user-email-or-object-id>" --scope "<foundry-scope>"
# Full ownership including data actions
az role assignment create --role "Azure AI Owner" --assignee "<user-email-or-object-id>" --scope "<foundry-scope>"
```
### 3. Audit Role Assignments
```bash
# List all assignments
az role assignment list --scope "<foundry-scope>" --output table
# Detailed with principal names
az role assignment list --scope "<foundry-scope>" --query "[].{Principal:principalName, PrincipalType:principalType, Role:roleDefinitionName}" --output table
# Azure AI roles only
az role assignment list --scope "<foundry-scope>" --query "[?contains(roleDefinitionName, 'Azure AI')].{Principal:principalName, Role:roleDefinitionName}" --output table
```
### 4. Validate Permissions
```bash
# Current user's roles on resource
az role assignment list --assignee "$(az ad signed-in-user show --query id -o tsv)" --scope "<foundry-scope>" --query "[].roleDefinitionName" --output tsv
# Check actions available to a role
az role definition list --name "Azure AI User" --query "[].permissions[].actions" --output json
```
**Permission Requirements by Action:**
| Action | Required Role(s) |
|--------|------------------|
| Deploy models | Azure AI User, Azure AI Project Manager, Azure AI Owner |
| Create projects | Azure AI Project Manager, Azure AI Account Owner, Azure AI Owner |
| Assign Azure AI User role | Azure AI Project Manager, Azure AI Account Owner, Azure AI Owner |
| Full data access | Azure AI User, Azure AI Project Manager, Azure AI Owner |
### 5. Configure Managed Identity Roles
```bash
# Get managed identity principal ID
PRINCIPAL_ID=$(az cognitiveservices account show --name <foundry-resource-name> --resource-group <resource-group> --query identity.principalId --output tsv)
# Assign roles to connected resources (repeat pattern for each)
az role assignment create --role "<role-name>" --assignee "$PRINCIPAL_ID" --scope "<resource-scope>"
```
**Common Managed Identity Role Assignments:**
| Connected Resource | Role | Purpose |
|--------------------|------|---------|
| Azure Storage | Storage Blob Data Reader | Read files/documents |
| Azure Storage | Storage Blob Data Contributor | Read/write files |
| Azure Key Vault | Key Vault Secrets User | Read secrets |
| Azure AI Search | Search Index Data Reader | Query indexes |
| Azure AI Search | Search Index Data Contributor | Query and modify indexes |
| Azure Cosmos DB | Cosmos DB Account Reader | Read data |
### 6. Create Service Principal for CI/CD
```bash
# Create SP with minimal role
az ad sp create-for-rbac --name "foundry-cicd-sp" --role "Azure AI User" --scopes "<foundry-scope>" --output json
# Output contains: appId, password, tenant โ store securely
# For project management permissions
az ad sp create-for-rbac --name "foundry-cicd-admin-sp" --role "Azure AI Project Manager" --scopes "<foundry-scope>" --output json
# Add Contributor for resource provisioning
SP_APP_ID=$(az ad sp list --display-name "foundry-cicd-sp" --query "[0].appId" -o tsv)
az role assignment create --role "Contributor" --assignee "$SP_APP_ID" --scope "/subscriptions/<subscription-id>/resourceGroups/<resource-group>"
```
> ๐ก **Tip:** Use least privilege โ start with `Azure AI User` and add roles as needed.
| CI/CD Scenario | Recommended Role | Additional Roles |
|----------------|------------------|------------------|
| Deploy models only | Azure AI User | None |
| Manage projects | Azure AI Project Manager | None |
| Full provisioning | Azure AI Owner | Contributor (on RG) |
| Read-only monitoring | Reader | Azure AI User (for data) |
**CI/CD Pipeline Login:**
```bash
az login --service-principal --username "<app-id>" --password "<client-secret>" --tenant "<tenant-id>"
az account set --subscription "<subscription-id>"
```
## Error Handling
| Issue | Cause | Resolution |
|-------|-------|------------|
| "Authorization failed" when deploying | Missing Azure AI User role | Assign Azure AI User role at resource scope |
| Cannot create projects | Missing Project Manager or Owner role | Assign Azure AI Project Manager role |
| "Access denied" on connected resources | Managed identity missing roles | Assign appropriate roles to MI on each resource |
| Portal works but CLI fails | Portal auto-assigns roles, CLI doesn't | Explicitly assign Azure AI User via CLI |
| Service principal cannot access data | Wrong role or scope | Verify Azure AI User is assigned at correct scope |
| "Principal does not exist" | User/SP not found in directory | Verify the assignee email or object ID is correct |
| Role assignment already exists | Duplicate assignment attempt | Use `az role assignment list` to verify existing assignments |
## Additional Resources
- [Azure AI Foundry RBAC Documentation](https://learn.microsoft.com/azure/ai-foundry/concepts/rbac-ai-foundry)
- [Azure Built-in Roles](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles)
- [Managed Identities Overview](https://learn.microsoft.com/azure/active-directory/managed-identities-azure-resources/overview)
- [Service Principal Authentication](https://learn.microsoft.com/azure/developer/github/connect-from-azure)
```
### references/sdk/foundry-sdk-py.md
```markdown
# Microsoft Foundry - Python SDK Guide
Python-specific implementations for working with Microsoft Foundry.
## Prerequisites
```bash
pip install azure-ai-projects azure-identity azure-ai-inference openai azure-ai-evaluation python-dotenv
```
### Environment Variables
```bash
PROJECT_ENDPOINT=https://<resource>.services.ai.azure.com/api/projects/<project>
MODEL_DEPLOYMENT_NAME=gpt-4o
AZURE_AI_SEARCH_CONNECTION_NAME=my-search-connection
AI_SEARCH_INDEX_NAME=my-index
AZURE_OPENAI_ENDPOINT=https://<resource>.openai.azure.com
AZURE_OPENAI_DEPLOYMENT=gpt-4o
```
## Model Discovery and Deployment (MCP)
```python
foundry_models_list() # All models
foundry_models_list(publisher="OpenAI") # Filter by publisher
foundry_models_list(search_for_free_playground=True) # Free playground models
foundry_models_deploy(
resource_group="my-rg", deployment="gpt-4o-deployment",
model_name="gpt-4o", model_format="OpenAI",
azure_ai_services="my-foundry-resource",
model_version="2024-05-13", sku_capacity=10, scale_type="Standard"
)
```
## RAG Agent with Azure AI Search
```python
import os
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
from azure.ai.agents.models import (
AzureAISearchToolDefinition, AzureAISearchToolResource,
AISearchIndexResource, AzureAISearchQueryType,
)
project_client = AIProjectClient(
endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
credential=DefaultAzureCredential(),
)
azs_connection = project_client.connections.get(
os.environ["AZURE_AI_SEARCH_CONNECTION_NAME"]
)
agent = project_client.agents.create_agent(
model=os.environ["FOUNDRY_MODEL_DEPLOYMENT_NAME"],
name="RAGAgent",
instructions="You are a helpful assistant. Use the knowledge base to answer. "
"Provide citations as: `[message_idx:search_idxโ source]`.",
tools=[AzureAISearchToolDefinition(
azure_ai_search=AzureAISearchToolResource(indexes=[
AISearchIndexResource(
index_connection_id=azs_connection.id,
index_name=os.environ["AI_SEARCH_INDEX_NAME"],
query_type=AzureAISearchQueryType.HYBRID,
),
])
)],
)
```
### Querying a RAG Agent (Streaming)
```python
openai_client = project_client.get_openai_client()
stream = openai_client.responses.create(
stream=True, tool_choice="required", input="Your question here",
extra_body={"agent": {"name": agent.name, "type": "agent_reference"}},
)
for event in stream:
if event.type == "response.output_text.delta":
print(event.delta, end="", flush=True)
elif event.type == "response.output_item.done":
if event.item.type == "message" and event.item.content[-1].type == "output_text":
for ann in event.item.content[-1].annotations:
if ann.type == "url_citation":
print(f"\nCitation: {ann.url}")
```
## Creating Agents
### Basic Agent
```python
agent = project_client.agents.create_agent(
model=os.environ["MODEL_DEPLOYMENT_NAME"],
name="my-agent",
instructions="You are a helpful assistant.",
)
```
### Agent with Custom Function Tools
```python
from azure.ai.agents.models import FunctionTool, ToolSet
def get_weather(location: str, unit: str = "celsius") -> str:
"""Get the current weather for a location."""
return f"Sunny and 22ยฐ{unit[0].upper()} in {location}"
functions = FunctionTool([get_weather])
toolset = ToolSet()
toolset.add(functions)
agent = project_client.agents.create_agent(
model=os.environ["MODEL_DEPLOYMENT_NAME"],
name="function-agent",
instructions="You are a helpful assistant with tool access.",
toolset=toolset,
)
```
### Agent with Web Search
```python
from azure.ai.agents.models import BingGroundingToolDefinition
agent = project_client.agents.create_agent(
model=os.environ["MODEL_DEPLOYMENT_NAME"],
name="WebSearchAgent",
instructions="Search the web for current information. Provide sources.",
tools=[BingGroundingToolDefinition()],
)
```
### Interacting with Agents
```python
from azure.ai.agents.models import ListSortOrder
thread = project_client.agents.threads.create()
project_client.agents.messages.create(thread_id=thread.id, role="user", content="Hello")
run = project_client.agents.runs.create_and_process(thread_id=thread.id, agent_id=agent.id)
if run.status == "failed":
print(f"Run failed: {run.last_error}")
messages = project_client.agents.messages.list(thread_id=thread.id, order=ListSortOrder.ASCENDING)
for msg in messages:
if msg.text_messages:
print(f"{msg.role}: {msg.text_messages[-1].text.value}")
project_client.agents.delete_agent(agent.id)
```
## Agent Evaluation
### Single Response Evaluation (MCP)
```python
foundry_agents_query_and_evaluate(
agent_id="<agent-id>", query="What's the weather?",
endpoint="https://my-foundry.services.ai.azure.com/api/projects/my-project",
azure_openai_endpoint="https://my-openai.openai.azure.com",
azure_openai_deployment="gpt-4o",
evaluators="intent_resolution,task_adherence,tool_call_accuracy"
)
foundry_agents_evaluate(
query="What's the weather?", response="Sunny and 22ยฐC.",
evaluator="intent_resolution",
azure_openai_endpoint="https://my-openai.openai.azure.com",
azure_openai_deployment="gpt-4o"
)
```
### Batch Evaluation
```python
from azure.ai.evaluation import AIAgentConverter, IntentResolutionEvaluator, evaluate
converter = AIAgentConverter(project_client)
converter.prepare_evaluation_data(thread_ids=["t1", "t2", "t3"], filename="eval_data.jsonl")
result = evaluate(
data="eval_data.jsonl",
evaluators={
"intent_resolution": IntentResolutionEvaluator(
azure_openai_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
azure_openai_deployment=os.environ["AZURE_OPENAI_DEPLOYMENT"]
),
},
output_path="./eval_results"
)
print(f"Results: {result['studio_url']}")
```
> ๐ก **Tip:** Continuous evaluation requires project managed identity with **Azure AI User** role and Application Insights connected to the project.
## Knowledge Index Operations (MCP)
```python
foundry_knowledge_index_list(endpoint="<project-endpoint>")
foundry_knowledge_index_schema(endpoint="<project-endpoint>", index="my-index")
```
## Best Practices
1. **Never hardcode credentials** โ use environment variables and `python-dotenv`
2. **Check `run.status`** and handle `HttpResponseError` exceptions
3. **Reuse `AIProjectClient`** instances โ don't create new ones per request
4. **Use type hints** in custom functions for better tool integration
5. **Use context managers** for agent cleanup
## Error Handling
```python
from azure.core.exceptions import HttpResponseError
try:
agent = project_client.agents.create_agent(
model=os.environ["MODEL_DEPLOYMENT_NAME"],
name="my-agent", instructions="You are helpful."
)
except HttpResponseError as e:
if e.status_code == 429:
print("Rate limited โ wait and retry with exponential backoff.")
elif e.status_code == 401:
print("Authentication failed โ check credentials.")
else:
print(f"Error: {e.message}")
```
### Context Manager for Agent Cleanup
```python
from contextlib import contextmanager
@contextmanager
def temporary_agent(project_client, **kwargs):
agent = project_client.agents.create_agent(**kwargs)
try:
yield agent
finally:
project_client.agents.delete_agent(agent.id)
```
```