Edit

Share via


Use skills in Foundry (preview)

Important

Items marked (preview) in this article are currently in public preview. This preview is provided without a service-level agreement, and we don't recommend it for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.

As agents grow beyond simple prototypes, teams accumulate behavioral guidelines that need to be consistent across every conversation. A support agent should always follow a specific escalation policy, a code-review agent should always apply the same checklist, and a sales agent should always respect certain messaging constraints. Embedding these guidelines directly in each agent's system prompt or code creates duplication: when the policy changes, you need to update and redeploy every agent that uses it.

Skills solve this problem by decoupling behavioral guidelines from agent code. A skill is a SKILL.md file you author once, store centrally in Foundry through the Skills REST API, and reference from any hosted agent. At startup, the agent downloads the skill files it needs and injects their contents as additional instructions into every conversation session. If you update a skill, every agent that references it picks up the change on its next deployment - no code changes required.

In this article, you learn how to:

  • Import, list, get, download, and delete skills by using the Skills REST API.
  • Bundle downloaded skills into a hosted agent.

Important

If you use Skills with any third-party servers, agents, code, or non-Azure Direct models ("Third-Party Systems"), you do so at your own risk. Third-Party Systems are Non-Microsoft Products under the Microsoft Product Terms and are governed by their own third-party license terms. You are responsible for any usage and associated costs.

We recommend reviewing all data being shared with and received from Third-Party Systems and being cognizant of third-party practices for handling, sharing, retention, and location of data. It is your responsibility to manage whether your data will flow outside of your organization’s Azure compliance and geographic boundaries and any related implications, and that appropriate permissions, boundaries, and approvals are provisioned.

You are responsible for carefully reviewing and testing applications you build in the context of your specific use cases and making all appropriate decisions and customizations. This includes implementing your own responsible AI mitigations, such as metaprompts, content filters, or other safety systems, and ensuring your applications meet appropriate quality, reliability, security, and trustworthiness standards. See the Azure OpenAI transparency note.

Feature support

Feature REST API Python .NET JavaScript Hosted agent Prompt agent
Skills CRUD (create, import, list, get, download, delete) ✔️ ✔️ ✔️ ✔️ N/A N/A
Include downloaded skills in agent N/A N/A N/A N/A ✔️ N/A

Important

Use skills in hosted agents only. The Skills REST API handles storage and retrieval. The hosted agent bundles the downloaded SKILL.md files into its container image and injects them at session startup.

Prerequisites

Author a skill

A skill is a Markdown file with a YAML front matter block:

---
name: greeting
description: Generate a personalized greeting for the user.
---

# Greeting Skill

You're a friendly greeting assistant for Foundry Hosted Agents.

## Instructions

- Include the user's name if they provided one.
- Keep greetings concise — 1 to 2 sentences.
- Thank the user for trying out Foundry Hosted Agents and this sample skill.
Field Required Rules
name Yes Short identifier, no spaces. Must be unquoted in YAML.
description Yes One-liner shown in skill listings. Must be unquoted in YAML.
Body Yes Free Markdown. Becomes the skill's injected instructions.

Important

  • The name and description values must be unquoted in the YAML front matter.
  • The use of quoted values (for example, name: 'greeting') causes an HTTP 500 error on import.

Place each skill in its own subdirectory under the agent root directory. For example, greeting/SKILL.md, not SKILL.md at the root.

Manage skills with the REST API

The Skills REST API stores skills centrally so any hosted agent in your Foundry project can download and use them.

Skills endpoint: {FOUNDRY_PROJECT_ENDPOINT}/skills

Authentication: Bearer token from DefaultAzureCredential with scope https://ai.azure.com/.default.

Create a skill

You can create a skill in two ways: submit the content directly as JSON, or upload a ZIP archive containing a SKILL.md file.

Option 1: Create from JSON

Use this option when you want to supply the skill's instructions text directly without packaging a file.

POST {endpoint}/skills?api-version=v1
Authorization: Bearer {token}
Content-Type: application/json
Accept: application/json

{
  "name": "greeting",
  "description": "Generate a personalized greeting for the user.",
  "instructions": "You are a friendly greeting assistant. Include the user's name and keep greetings concise."
}
import os
from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient

endpoint = os.environ["FOUNDRY_PROJECT_ENDPOINT"]

with (
    DefaultAzureCredential() as credential,
    AIProjectClient(
        endpoint=endpoint, credential=credential, allow_preview=True
    ) as project_client,
):
    created = project_client.beta.skills.create(
        name="greeting",
        description="Generate a personalized greeting for the user.",
        instructions="You are a friendly greeting assistant. Include the user's name and keep greetings concise.",
    )
    print(
        f"Created skill: {created.name} ({created.skill_id}) "
        f"has_blob={created.has_blob}"
    )
#pragma warning disable AAIP001
using Azure.AI.Projects.Agents;
using Azure.Core.Pipeline;
using Azure.Identity;

var projectEndpoint = Environment.GetEnvironmentVariable("FOUNDRY_PROJECT_ENDPOINT");
AgentAdministrationClientOptions options = new();
options.AddPolicy(new FeaturePolicy("Skills=V1Preview"), PipelinePosition.PerCall);
AgentAdministrationClient adminClient = new(new Uri(projectEndpoint), new DefaultAzureCredential(), options);
AgentSkills skillsClient = adminClient.GetAgentSkills();

AgentsSkill created = skillsClient.CreateSkill(
    name: "greeting",
    description: "Generate a personalized greeting for the user.",
    instructions: "You are a friendly greeting assistant. Include the user's name and keep greetings concise."
);
Console.WriteLine($"Created skill: {created.Name} ({created.SkillId}) HasBlob={created.HasBlob}");

// FeaturePolicy: inject the preview feature header on every request.
internal class FeaturePolicy(string feature) : PipelinePolicy
{
    public override void Process(PipelineMessage msg, IReadOnlyList<PipelinePolicy> pipeline, int idx)
    {
        msg.Request.Headers.Add("Foundry-Features", feature);
        ProcessNext(msg, pipeline, idx);
    }
    public override async ValueTask ProcessAsync(PipelineMessage msg, IReadOnlyList<PipelinePolicy> pipeline, int idx)
    {
        msg.Request.Headers.Add("Foundry-Features", feature);
        await ProcessNextAsync(msg, pipeline, idx);
    }
}
import { DefaultAzureCredential } from "@azure/identity";
import { AIProjectClient } from "@azure/ai-projects";

const projectEndpoint = process.env["FOUNDRY_PROJECT_ENDPOINT"] || "<project endpoint>";
const project = new AIProjectClient(projectEndpoint, new DefaultAzureCredential());

const skill = await project.beta.skills.create("greeting", {
  description: "Generate a personalized greeting for the user.",
  instructions: "You are a friendly greeting assistant. Include the user's name and keep greetings concise.",
});
console.log(`Created skill: ${skill.name} (id: ${skill.skillId})`);

Example response:

{
  "id": "skill_abc123",
  "object": "skill",
  "name": "greeting",
  "description": "Generate a personalized greeting for the user.",
  "instructions": "You are a friendly greeting assistant. ...",
  "has_blob": false,
  "created_at": 1741305600
}

Option 2: Import from a SKILL.md ZIP

Use this option when you have a SKILL.md file. Package it as a ZIP and POST to the :import endpoint. The skill name and description come from the SKILL.md front matter. The request body must be a valid ZIP file with a SKILL.md entry at the root.

POST {endpoint}/skills:import?api-version=v1
Authorization: Bearer {token}
Content-Type: application/zip
Accept: application/json
Foundry-Features: Skills=V1Preview

<ZIP bytes containing SKILL.md at the root>
import os
from pathlib import Path
from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient

endpoint = os.environ["FOUNDRY_PROJECT_ENDPOINT"]

with (
    DefaultAzureCredential() as credential,
    AIProjectClient(
        endpoint=endpoint, credential=credential, allow_preview=True
    ) as project_client,
):
    imported = project_client.beta.skills.create_from_package(
        Path("greeting.zip").read_bytes()
    )
    print(
        f"Imported skill: {imported.name} ({imported.skill_id}) "
        f"has_blob={imported.has_blob}"
    )
#pragma warning disable AAIP001
// See the FeaturePolicy class definition and client setup in the Create a skill section above.

// CreateSkillFromPackage accepts a local directory path containing a SKILL.md file.
AgentsSkill imported = skillsClient.CreateSkillFromPackage("path/to/skill-directory");
Console.WriteLine($"Imported skill: {imported.Name} ({imported.SkillId}) HasBlob={imported.HasBlob}");
import { readFileSync } from "fs";

const zipBytes = readFileSync("greeting.zip");
const skill = await project.beta.skills.createFromPackage(zipBytes);
console.log(`Imported skill: ${skill.name} (has_blob: ${skill.hasBlob})`);

Note

The ZIP must contain SKILL.md at the root, not in a subdirectory.

Example response:

{
  "id": "skill_def456",
  "object": "skill",
  "name": "greeting",
  "description": "Generate a personalized greeting for the user.",
  "has_blob": true,
  "created_at": 1741305600
}

has_blob: true means the skill was created from a ZIP and can be downloaded. Skills created from JSON have has_blob: false and can't be downloaded.

List skills

GET {endpoint}/skills?api-version=v1&limit=20&order=desc
Authorization: Bearer {token}
Accept: application/json
Foundry-Features: Skills=V1Preview
import os
from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient

endpoint = os.environ["FOUNDRY_PROJECT_ENDPOINT"]

with (
    DefaultAzureCredential() as credential,
    AIProjectClient(
        endpoint=endpoint, credential=credential, allow_preview=True
    ) as project_client,
):
    skills = list(project_client.beta.skills.list())
    print(f"Found {len(skills)} skill(s)")
    for skill in skills:
        print(f"  {skill.name} (has_blob: {skill.has_blob})")
#pragma warning disable AAIP001
// See the FeaturePolicy class definition and client setup in the Create a skill section above.

List<AgentsSkill> skills = [.. skillsClient.GetSkills()];
Console.WriteLine($"Found {skills.Count} skill(s).");
foreach (AgentsSkill item in skills)
{
    Console.WriteLine($"  - {item.Name} ({item.SkillId})");
}
const skills = project.beta.skills.list({ limit: 20, order: "desc" });
for await (const skill of skills) {
  console.log(`${skill.name} (has_blob: ${skill.hasBlob})`);
}

Example response:

{
  "object": "list",
  "data": [
    {
      "id": "skill_abc123",
      "object": "skill",
      "name": "greeting",
      "description": "Generate a personalized greeting for the user.",
      "has_blob": true,
      "created_at": 1741305600
    }
  ],
  "has_more": false,
  "first_id": "skill_abc123",
  "last_id": "skill_abc123"
}

Use first_id and last_id with the after or before query parameters for cursor-based pagination.

Get a skill

GET {endpoint}/skills/{name}?api-version=v1
Authorization: Bearer {token}
Accept: application/json
Foundry-Features: Skills=V1Preview
import os
from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient

endpoint = os.environ["FOUNDRY_PROJECT_ENDPOINT"]

with (
    DefaultAzureCredential() as credential,
    AIProjectClient(
        endpoint=endpoint, credential=credential, allow_preview=True
    ) as project_client,
):
    skill = project_client.beta.skills.get("greeting")
    print(f"{skill.name}: {skill.description}")
#pragma warning disable AAIP001
// See the FeaturePolicy class definition and client setup in the Create a skill section above.

AgentsSkill skill = skillsClient.GetSkill(skillName: "greeting");
Console.WriteLine($"Retrieved skill: {skill.Name}, description: {skill.Description}");
const skill = await project.beta.skills.get("greeting");
console.log(`${skill.name}: ${skill.description}`);

Returns the skill metadata. Returns HTTP 404 if the skill doesn't exist.

Download a skill

Downloads the original ZIP archive for skills created through :import (has_blob: true). Returns HTTP 404 for skills created through JSON.

GET {endpoint}/skills/{name}:download?api-version=v1
Authorization: Bearer {token}
Accept: application/zip
Foundry-Features: Skills=V1Preview
import os
import tempfile
from datetime import datetime
from pathlib import Path
from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient

endpoint = os.environ["FOUNDRY_PROJECT_ENDPOINT"]
download_folder = Path(tempfile.gettempdir()).resolve()

with (
    DefaultAzureCredential() as credential,
    AIProjectClient(
        endpoint=endpoint, credential=credential, allow_preview=True
    ) as project_client,
):
    timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
    download_path = download_folder / f"greeting_{timestamp}.zip"
    download_path.write_bytes(
        b"".join(project_client.beta.skills.download("greeting"))
    )
    print(f"Downloaded skill package to: {download_path}")

Note

.NET sample isn't available yet.

const response = await project.beta.skills.download("greeting");
// response.body contains the ZIP archive bytes

Note

The response body is a binary ZIP archive (Content-Type: application/zip).

Delete a skill

DELETE {endpoint}/skills/{name}?api-version=v1
Authorization: Bearer {token}
Accept: application/json
Foundry-Features: Skills=V1Preview
import os
from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient

endpoint = os.environ["FOUNDRY_PROJECT_ENDPOINT"]

with (
    DefaultAzureCredential() as credential,
    AIProjectClient(
        endpoint=endpoint, credential=credential, allow_preview=True
    ) as project_client,
):
    deleted = project_client.beta.skills.delete("greeting")
    print(f"Deleted skill: {deleted}")
#pragma warning disable AAIP001
// See the FeaturePolicy class definition and client setup in the Create a skill section above.

skillsClient.DeleteSkill("greeting");
Console.WriteLine("Skill deleted.");
const result = await project.beta.skills.delete("greeting");
console.log(`Deleted: ${result.name} (${result.deleted})`);

Returns HTTP 200 on success:

{
  "id": "skill_abc123",
  "object": "skill.deleted",
  "name": "greeting",
  "deleted": true
}

Use skills in a hosted agent

After importing skills to Foundry, download them and bundle them into your hosted agent's container image. The agent discovers them at startup and injects them as additional instructions in every session.

Step 1: Download skills into the agent directory

Download each skill into its own subdirectory under the agent root. Use the download operation from Download a skill.

When the downloads are complete, the agent directory looks like this:

my-agent/
├── main.py
├── greeting/
│   └── SKILL.md        ← downloaded from Foundry
└── another-skill/
    └── SKILL.md

Step 2: Initialize the agent locally

After downloading the skills, initialize the agent. The agent autodiscovers skills at startup by scanning the project root for any */SKILL.md pattern.

azd ai agent init --skills --name my-agent

Start the local agent:

azd ai agent start

Test the local agent:

azd ai agent invoke "What Azure products do you offer?"

Step 3: Deploy and test the hosted agent

Deploy the agent:

azd ai agent deploy

Test the remote hosted agent:

azd ai agent invoke --remote "What Azure products do you offer?"