agentleFS
MicrosoftKnown publishermicrosoft/fabric-org-app-template/.agents/skills/org-app-fetch/SKILL.md

org-app-fetch

Skill1 starsChanged 6 months agoMITView on GitHub

Fetch a Power BI Org App artifact envelope from the Power BI cluster. Use when the user provides an Org App ID and wants to migrate it into this template. Acquires an Azure CLI token, discovers the tenant's home cluster, and pulls the raw JSON envelope so org-app-parsing can extract the manifest.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are 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.

  • 3

    Very specific

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

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

    When the user wants to migrate a Power BI Org App into this template.

    line 10
  2. Distinctive:

    Ask the user to confirm they are signed in to the correct tenant with Azure CLI:

    line 31
  3. Very specific:

    Before passing to org-app-parsing, confirm:

    line 81
  4. Very specific:

    If artifactType !== "OrgApp", abort — the ID belongs to a different artifact type.

    line 90

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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

org-app-fetch

When to use this skill

When the user wants to migrate a Power BI Org App into this template. They will provide an Org App ID (a GUID like 1b663c51-10f8-4fdf-8863-d24e49622988).

Why this exists (constraints)

The public Fabric REST /items endpoint does not expose OrgApp as a recognized ItemType. The public Power BI Apps REST (/v1.0/myorg/apps/{id}) returns 404 for V3 Org App IDs because V3 is a different artifact model.

The endpoint used is the one the Power BI portal calls at runtime:

GET {clusterUrl}/metadata/artifacts/{orgAppId}

This requires:

  1. A bearer token scoped to https://analysis.windows.net/powerbi/api
  2. The tenant's home clusterUrl (different per tenant + environment)

Step-by-step workflow

1. Get a token

Ask the user to confirm they are signed in to the correct tenant with Azure CLI:

az account show --query "{user: user.name, tenantId: tenantId}"

Then acquire the token:

$token = (az account get-access-token --resource https://analysis.windows.net/powerbi/api --query accessToken -o tsv)

⚠️ The Org App must be in the same tenant as the signed-in user. Cross-tenant migration is not supported by this skill.

2. Capture the tenant ID

$tenantId = (az account show --query tenantId -o tsv)

Save this — it goes into the manifest's tenantId field for the secure embed URL.

3. Discover the cluster URL

The tenant's home cluster is returned by the Power BI global service as a ClusterUri cookie:

$headerFile = New-TemporaryFile
curl.exe -s -D $headerFile.FullName -H "Authorization: Bearer $token" `
    "https://api.powerbi.com/powerbi/globalservice/v201606/clusterdetails" | Out-Null
$headers = Get-Content $headerFile.FullName -Raw
Remove-Item $headerFile.FullName -Force

$cookieMatch = ($headers | Select-String -Pattern 'ClusterUri=[^=]+=([^;]+)').Matches
if (-not $cookieMatch) {
    throw "Cluster discovery failed — no ClusterUri cookie found. Check that `$token is valid."
}
$cluster = $cookieMatch[0].Groups[1].Value.TrimEnd('/')

The same logic is implemented in code at src/lib/fabricUrls.ts (getPowerBIGlobalServiceOrigin) and consumed by src/lib/cluster.ts. Keep them in sync.

4. Fetch the Org App envelope

$envelope = curl.exe -s -H "Authorization: Bearer $token" "$cluster/metadata/artifacts/$orgAppId" | ConvertFrom-Json

5. Sanity-check the response

Before passing to org-app-parsing, confirm:

FieldExpected
artifactType"OrgApp"
payloadContentType"InlineJson"
workloadPayloadnon-empty JSON-encoded string
folderObjectIdnon-empty GUID (this is the workspace ID)

If artifactType !== "OrgApp", abort — the ID belongs to a different artifact type.

What to pass to the next skill

Hand off the parsed $envelope object plus $tenantId to org-app-parsing.

Common errors

SymptomCauseFix
401 UnauthorizedToken expired or wrong resourceRe-run step 1; verify --resource is exactly https://analysis.windows.net/powerbi/api
403 ForbiddenUser lacks access to the Org AppAsk the user to confirm they are a viewer of the Org App in app.powerbi.com
404 Not FoundWrong tenant, or ID is not an Org AppConfirm tenant via az account show, then verify the ID by opening the Org App in the Fabric portal (e.g. https://app.fabric.microsoft.com/groups/me/apps/<id>).
clusterUrl is nullToken was acquired for the wrong resourceRe-acquire with the exact resource above
Cluster discovery threw "no ClusterUri cookie found"No cluster cookie in the responseToken is invalid or expired. Re-acquire the token (step 1).

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.