AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified MIT Self-run

Byok 401 Debug Expert

skill-aiappsgbb-awesome-gbb-byok-401-debug-expert · by aiappsgbb

Diagnose the silent BYOK 401 that Foundry hosted agents emit when "Foundry User" RBAC is assigned at PROJECT scope but missing at the underlying CognitiveServices ACCOUNT scope. Encodes the exact fix command.

No reviews yet
0 installs
13 views
0.0% view→install

Install

$ agentstack add skill-aiappsgbb-awesome-gbb-byok-401-debug-expert

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access Used
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-aiappsgbb-awesome-gbb-byok-401-debug-expert)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
1mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Byok 401 Debug Expert? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

byok401debug_expert

Background

When a Foundry hosted agent uses BYOK (bring-your-own-key) against a customer-owned Azure OpenAI account, the agent's identity needs Foundry User (RoleDefinitionId 53ca6127-db72-4b80-b1b0-d745d6d5456d) assigned at TWO scopes:

  • Project scopeazd ai agent deploy assigns this automatically
  • CognitiveServices account scope — NOT assigned automatically

Without the account-scope role, the agent starts and accepts /invoke calls (returns 200 with SSE stream), but the FIRST event in the stream is an error with the 401. This is the silent BYOK 401.

Investigation flow

  1. Get the agent's identity:

``bash az cognitiveservices account show --name --resource-group --query "identity" -o json az ml online-endpoint show --workspace-name --resource-group --name --query "identity" -o json ``

  1. List role assignments on the BYOK CognitiveServices account:

``bash az role assignment list \ --scope /subscriptions//resourceGroups//providers/Microsoft.CognitiveServices/accounts/ \ --role "Foundry User" -o table ``

  1. Match against the agent's identity. If the agent's UAMI

principalId (or its instance_identity.principal_id) is NOT in the role assignment list at the ACCOUNT scope — that's the root cause.

  1. Verify the symptom in App Insights:

``kql traces | where timestamp > ago(2h) | where cloud_RoleName == "" | where message contains "Authentication failed with provider" | project timestamp, message, customDimensions ``

  1. Output the exact fix for the human to run:

``bash az role assignment create \ --assignee \ --role "Foundry User" \ --scope /subscriptions//resourceGroups//providers/Microsoft.CognitiveServices/accounts/ ` Also grant to blueprint.principal_id if azd ai agent show` reveals a separate blueprint identity.

  1. Provide a one-line invoke to verify after the fix:

``bash curl -X POST /api/v1/invoke -H "Content-Type: application/json" -d '{"input":"hello"}' ``

Reference

  • foundry-hosted-agents KI-001 — RBAC postdeploy hook gap
  • ghcp-hosted-agents KI-002 — silent BYOK 401 SSE pattern
  • Role GUID is stable across Foundry "Azure AI User" → "Foundry User" rename (May 2026)

Tools

  • RunAzCliReadCommands
  • QueryAppInsightsByAppId

Safety

  • Never display BYOK keys, connection strings, or token contents
  • Hand the human the exact az role assignment create command — never run it yourself

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.