agentleFS
soulemikesoulemike/microsoft-skills/skills/graph/SKILL.md

graph

Skill2 starsChanged 3 months agoMITView on GitHub

Use this skill for unattended Microsoft Graph automation with app-only authentication, sovereign cloud awareness, pagination, and throttling-aware REST calls.

25 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use understand, ingest and 8 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • agoodwaySkill

    understand

    Multi-specialist collaborative analysis to understand how features, functions, or components work

    Also in 3 projects that use this

  • JaimeGBASkill

    ingest

    Digest an external source (article, paper, transcript, URL, book chapter) and integrate its content into the knowledge base

    Also in 4 projects that use this

  • genomewalkerSkill

    explore

    RLM-style recursive memory exploration - dynamically navigate the memory graph

    Also in 3 projects that use this

  • MicrosoftSkill

    init

    Also in 3 projects that use this

  • AnthropicSkill

    start

    Set up your bio-research environment and explore available tools. Use when first getting oriented with the plugin, checking which literature, drug-discovery, or visualization MCP servers are connected, or surveying available analysis skills before starting a new project.

    Also in 3 projects that use this

  • AnthropicSkill

    debug

    Structured debugging session — reproduce, isolate, diagnose, and fix. Trigger with an error message or stack trace, "this works in staging but not prod", "something broke after the deploy", or when behavior diverges from expected and the cause isn't obvious.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 3 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 20 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use this skill when an agent needs Microsoft Graph app-only automation without interactive sign-in.

    line 22
  2. Distinctive:

    Run the same automation in Azure commercial, US Gov, or China clouds.

    line 26
  3. Distinctive:

    Follow Graph pagination and handle throttling without reimplementing retry logic.

    line 27
  4. Very specific:

    Prefer ManagedIdentity or Federated authentication.

    line 63
  5. Distinctive:

    Never assume delegated/user auth is available.

    line 64

“Common” is measured: kept by at least 6 in 10 of the 20 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Microsoft Graph Skill

Agent Summary

Use this skill when an agent needs Microsoft Graph app-only automation without interactive sign-in. Start by creating a context with Connect-GraphApi.ps1, then send relative Graph paths or absolute @odata.nextLink URLs to Invoke-GraphRequest.ps1.

When to Use

  • Query Microsoft Entra ID objects such as users, groups, applications, or service principals.
  • Run the same automation in Azure commercial, US Gov, or China clouds.
  • Follow Graph pagination and handle throttling without reimplementing retry logic.

Required Parameters

Connect-GraphApi.ps1

ParameterTypeRequiredNotes
AuthenticationTypestringConditionalManagedIdentity, Federated, Certificate, or ClientCredentials.
EnvironmentstringNoDefaults to AzureCloud.
TenantIdstringConditionalRequired for Federated, Certificate, and ClientCredentials.
ClientIdstringConditionalRequired for Federated, Certificate, and ClientCredentials; optional for user-assigned managed identity.
FederatedTokenstringConditionalRequired for Federated.
CertificatePathstringConditionalRequired for Certificate.
ClientSecretSecureStringConditionalRequired for ClientCredentials.

Invoke-GraphRequest.ps1

ParameterTypeRequiredNotes
UristringYesRelative Graph path or absolute nextLink URL.
AuthContexthashtableYesOutput from Connect-GraphApi.ps1.
MethodstringNoDefaults to GET.
BodyobjectNoRequest payload for writes.
PaginateswitchNoAggregate @odata.nextLink pages.

Example Agent Prompts

  • "List all Microsoft Graph users with id, displayName, and mail."
  • "Get a specific group from Microsoft Graph by ID using app-only auth."
  • "Follow all pages for a Graph query and return the aggregated results."

Example Agent Workflow

$context = ./skills/graph/Connect-GraphApi.ps1 -AuthenticationType ManagedIdentity -Environment AzureCloud

$users = ./skills/graph/Invoke-GraphRequest.ps1 -AuthContext $context -Uri "/users?`$select=id,displayName,mail" -Paginate

Security Caveats

  • Prefer ManagedIdentity or Federated authentication; use client secrets only as a last resort.
  • Never assume delegated/user auth is available; this skill is designed for app-only execution.
  • Grant only the minimum Graph application permissions required for the requested operation.

Overview

This skill domain covers unattended Microsoft Graph API automation using app-only authentication. It provides a standardized way to acquire Graph tokens for different Azure environments and invoke Graph REST requests with pagination and throttling-aware retries.

Authentication

Endpoints

EnvironmentGraph Endpoint
AzureCloudhttps://graph.microsoft.com
AzureUSGovernmenthttps://graph.microsoft.us
AzureChinaCloudhttps://microsoftgraph.chinacloudapi.cn

Skills

FilePurpose
Connect-GraphApi.ps1Resolves the selected Azure environment and returns a Graph auth context (token, expiry, Graph endpoint, and BaseUri) suitable for Invoke-GraphRequest.
Invoke-GraphRequest.ps1Invokes Microsoft Graph REST requests (relative Graph paths or absolute nextLink URLs), with optional @odata.nextLink pagination aggregation and throttling-aware retries.
auth/*.ps1Token acquisition wrappers for each supported auth type (ManagedIdentity, FederatedCredentials, CertificateBased, ClientCredentials), producing a Graph authentication context.

Toolchain

ToolBest ForToken AudienceLimitations in Graph Context
Microsoft.Graph PowerShell SDK (Microsoft.Graph.*)Rich Graph entity coverage, strong typing, pagination handled automaticallyhttps://graph.microsoft.com/ (or gov/china equivalent)Large module footprint; some beta endpoints lag behind REST API; app-only vs delegated context can be confusing
Az PowerShell modules (Az.Accounts)Token chaining from Azure context to Graphhttps://graph.microsoft.com/ via Get-AzAccessToken -ResourceTypeName MSGraphLimited to token acquisition; does not provide Graph SDK features
Raw REST (Invoke-RestMethod)Full control over Graph API versions (beta, v1.0), headers, and query parametershttps://graph.microsoft.com/Caller must handle pagination (@odata.nextLink), throttling (Retry-After), and token refresh manually

Patterns & Caveats

  • Pagination: Invoke-GraphRequest supports -Paginate, which follows @odata.nextLink (default) and aggregates the response payload from the value property.
  • Throttling: Invoke-GraphRequest retries on HTTP 429 and 5xx responses, and it uses the Retry-After response header when present.
  • $select usage: Put $select in the -Uri query to reduce response payload size, especially for list endpoints you plan to paginate.
  • App-only context requirements: tokens are acquired for the Graph resource endpoint (https://graph.microsoft.com or the sovereign equivalent). When you call Invoke-GraphRequest, your app registration must have the required application permissions for the operations you perform.

Examples

# 1) Managed identity: list users with $select and pagination
$context = ./skills/graph/Connect-GraphApi.ps1 -AuthenticationType ManagedIdentity -Environment AzureCloud

$users = ./skills/graph/Invoke-GraphRequest.ps1 -AuthContext $context -Uri "/users?`$select=id,displayName,mail" -Paginate
# 2) Federated credentials: get a single group
$context = ./skills/graph/Connect-GraphApi.ps1 `
  -AuthenticationType Federated `
  -TenantId $env:AZURE_TENANT_ID `
  -ClientId $env:AZURE_CLIENT_ID `
  -FederatedToken $env:AZURE_FEDERATED_TOKEN `
  -Environment AzureCloud

$group = ./skills/graph/Invoke-GraphRequest.ps1 -AuthContext $context -Uri "/groups/$groupId?`$select=id,displayName"
# 3) Use an absolute nextLink URL directly
$context = ./skills/graph/Connect-GraphApi.ps1 -AuthenticationType Certificate -TenantId $env:AZURE_TENANT_ID -ClientId $env:AZURE_CLIENT_ID -CertificatePath "/secure/certs/graph.pfx" -Environment AzureCloud

# First page (no aggregation)
$firstPage = ./skills/graph/Invoke-GraphRequest.ps1 -AuthContext $context -Uri "/users?`$select=id,displayName&`$top=1"

# Second page, calling Invoke-GraphRequest with the absolute nextLink URL
$secondPage = ./skills/graph/Invoke-GraphRequest.ps1 -AuthContext $context -Uri $firstPage."@odata.nextLink"
# 4) Use a config.yaml profile
$context = ./skills/graph/Connect-GraphApi.ps1 -Profile "prod" -ConfigPath "./config.yaml"
# 5) Use prefixed environment variables
$context = ./skills/graph/Connect-GraphApi.ps1 -Prefix "GOV" -Environment AzureUSGovernment

Prerequisites

  • Required modules: the skill scripts require PowerShell 7.2+. For certificate-based token acquisition, MSAL.PS is used if available; otherwise the scripts fall back to Azure CLI (az) for the access token.
  • Required permissions (application permissions): configure Microsoft Graph application permissions on the app registration used by your auth method. The scripts request tokens for the Graph resource endpoint and then call Graph with that token.

Related Docs

  • Auth Patterns
  • Token Chaining
  • Environment Endpoints

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.