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

dataverse

Skill2 starsChanged 3 months agoMITView on GitHub

Use this skill for Microsoft Dataverse Web API automation with OData queries, environment-aware authentication, and pagination-aware REST calls.

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

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

    Use this skill for Dataverse Web API requests when an agent needs direct OData access instead of PAC CLI abstractions.

    line 22
  2. Distinctive:

    Prefer managed identity or federated credentials over client secrets.

    line 65

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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

Dataverse Skill

Agent Summary

Use this skill for Dataverse Web API requests when an agent needs direct OData access instead of PAC CLI abstractions. The token audience is the Dataverse environment URL itself, so start by creating a context with Connect-DataverseApi.ps1.

When to Use

  • Query Dataverse tables with OData filters, selects, and pagination.
  • Connect to a known Dataverse environment or discover one through the Global Discovery Service.
  • Perform direct CRUD operations against Dataverse entities.

Required Parameters

Connect-DataverseApi.ps1

ParameterTypeRequiredNotes
EnvironmentUrlstringYesDataverse environment root URL or full Web API URL.
AuthenticationTypestringConditionalManagedIdentity, Federated, Certificate, or ClientCredentials.
EnvironmentstringNoDefaults to AzureCloud.
TenantIdstringConditionalRequired for Federated, Certificate, and ClientCredentials.
ClientIdstringConditionalRequired for Federated, Certificate, and ClientCredentials.
FederatedTokenstringConditionalRequired for Federated.
CertificatePathstringConditionalRequired for Certificate.
ClientSecretSecureStringConditionalRequired for ClientCredentials.

Invoke-DataverseRequest.ps1

ParameterTypeRequiredNotes
UristringYesRelative Dataverse API path or absolute nextLink URL.
AuthContexthashtableYesOutput from Connect-DataverseApi.ps1.
MethodstringNoDefaults to GET.
BodyobjectNoRequest payload for writes.
PaginateswitchNoAggregates @odata.nextLink pages.

Example Agent Prompts

  • "List the first 50 Dataverse accounts with accountid and name."
  • "Query Dataverse contacts where emailaddress1 is not null."
  • "Patch a Dataverse account record by ID."

Example Agent Workflow

$ctx = ./skills/dataverse/Connect-DataverseApi.ps1 -AuthenticationType ManagedIdentity -Environment AzureCloud -EnvironmentUrl $env:DATAVERSE_ENVIRONMENT_URL

$accounts = ./skills/dataverse/Invoke-DataverseRequest.ps1 -AuthContext $ctx -Uri "/accounts?`$select=accountid,name&`$top=50" -Paginate

Security Caveats

  • The Dataverse environment URL is the token audience; do not substitute Graph or ARM tokens.
  • Prefer managed identity or federated credentials over client secrets.
  • Grant only the Dataverse roles and table permissions required for the requested entity operations.

Overview

This skillset connects to Microsoft Dataverse Web API and executes OData requests with consistent auth, environment discovery, and retry behavior.

Authentication

  • Auth types: ManagedIdentity, Federated, Certificate, ClientCredentials (emits a mandatory warning when using client secrets).
  • Token audience is the environment URL itself (not Graph or ARM). The environment root URL is used as the OAuth resource, so the token is scoped with $Resource/.default.
  • Global Discovery Service for environment lookup to translate an environment URL into the correct Web API base URI.

Endpoints

EnvironmentGDS EndpointEnvironment URL Pattern
AzureCloudhttps://globaldisco.crm.dynamics.comhttps://*.crm.dynamics.com
AzureUSGovernmenthttps://globaldisco.crm9.dynamics.comhttps://*.crm9.dynamics.com
AzureChinaCloudhttps://globaldisco.crm.dynamics.cnhttps://*.crm.dynamics.cn

Skills

FilePurpose
Connect-DataverseApi.ps1Establishes the Dataverse Web API connection context, resolves the Web API base URI (via GDS when -Environment is provided), and acquires the bearer token.
Invoke-DataverseRequest.ps1Sends Dataverse Web API requests with Dataverse-specific OData headers, supports @odata.nextLink pagination via -Paginate, and handles relative versus absolute URIs.
Get-DataverseEnvironment.ps1Queries the Global Discovery Service (GDS) for available Dataverse environments for the selected cloud.
auth/*.ps1Thin wrappers that fix AuthenticationType to ManagedIdentity, Federated, Certificate, or ClientCredentials.

Toolchain

ToolBest ForToken AudienceLimitations in Dataverse Context
PAC CLI (pac)Solution packaging, environment management, agent deploymentPower Platform admin scope; internally handles Dataverse token acquisitionDoes not expose all Dataverse entity fields; limited to supported operations; cannot perform arbitrary OData queries
Raw REST (Invoke-RestMethod)Full OData query flexibility, custom entity operations, file uploads/downloadsDataverse environment URL (e.g., https://*.crm.dynamics.com)Caller must handle pagination, throttling, retry logic, and token refresh manually

Patterns & Caveats

  • OData query syntax
  • File uploads/downloads need special handling
  • Pagination
  • Environment URL as token audience

Examples

# 1) GDS lookup, then run an OData query with pagination
$authToken = $env:AZURE_FEDERATED_TOKEN

$environments = Get-DataverseEnvironment.ps1 \
  -AuthenticationType Federated \
  -TenantId $env:TENANT_ID \
  -ClientId $env:CLIENT_ID \
  -FederatedToken $authToken \
  -Environment AzureCloud

$target = $environments | Where-Object { $_.UniqueName -eq 'contoso' } | Select-Object -First 1

$ctx = Connect-DataverseApi.ps1 \
  -AuthenticationType Federated \
  -TenantId $env:TENANT_ID \
  -ClientId $env:CLIENT_ID \
  -FederatedToken $authToken \
  -Environment AzureCloud \
  -EnvironmentUrl $target.url

$accounts = Invoke-DataverseRequest.ps1 \
  -AuthContext $ctx \
  -Uri "/accounts?`$select=accountid,name&`$top=5000" \
  -Paginate
# 2) Certificate-based auth and a filtered OData query
$ctx = Connect-DataverseApi.ps1 \
  -AuthenticationType Certificate \
  -TenantId $env:TENANT_ID \
  -ClientId $env:CLIENT_ID \
  -CertificatePath "/secure/certs/app.pfx" \
  -Environment AzureCloud \
  -EnvironmentUrl $env:DATAVERSE_ENVIRONMENT_URL

$contacts = Invoke-DataverseRequest.ps1 \
  -AuthContext $ctx \
  -Uri "/contacts?`$select=contactid,fullname,emailaddress1&`$filter=emailaddress1 ne null" \
  -Paginate
# 3) Patch a record using the Dataverse Web API
$ctx = Connect-DataverseApi.ps1 \
  -AuthenticationType ManagedIdentity \
  -Environment AzureCloud \
  -EnvironmentUrl $env:DATAVERSE_ENVIRONMENT_URL

$accountId = "00000000-0000-0000-0000-000000000001"

Invoke-DataverseRequest.ps1 \
  -AuthContext $ctx \
  -Method PATCH \
  -Uri "/accounts($accountId)" \
  -Body @{ name = 'Contoso Updated Account' }

Prerequisites

  • Required modules: PowerShell 7.2+; Az.Accounts, Az.Resources, and Azure modules installed via prerequisites/Install-RequiredModules.ps1 (MSAL.PS optional for certificate validation).
  • Required permissions: An Entra ID app registration with Dataverse Web API access for the specific Dataverse environment (the token audience is the environment URL), plus Dataverse security roles that permit the entity reads and writes you will perform.

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.