-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Description
a365 cleanup blueprint deletes the blueprint Entra ID application and messaging endpoint, but does not check for or clean up any agent instances (agent identity service principal + agentic user) that were created from that blueprint.
This leaves orphaned resources in Entra ID that cannot be cleaned up by a365 cleanup instance (see related issue).
Steps to Reproduce
a365 setup all— creates blueprint + deploys infrastructurea365 publish— publishes blueprint to MOS catalog- Admin activates blueprint, user creates instance → agent identity SP + agentic user created
a365 cleanup blueprint— deletes blueprint app, federated credentials, and messaging endpoint- Agent identity SP and agentic user remain in Entra ID with no parent blueprint
Expected Behavior
cleanup blueprint should either:
- Option A: Detect active instances and warn/refuse to delete until instances are cleaned up first
- Option B: Cascade cleanup — delete instances (identity SP + agentic user) before deleting the blueprint
- Option C: At minimum, warn the user that orphaned instances will remain
Actual Behavior
Blueprint is deleted silently. The agent identity SP (servicePrincipalType: ServiceIdentity) and agentic user remain in Entra ID. These orphaned resources:
- Still appear in
GET /beta/servicePrincipals/microsoft.graph.agentIdentity - Still appear in
GET /beta/agentUsers - Cannot be cleaned up via
a365 cleanup instance(separate bug —AgenticAppId/AgenticUserIdare never populated) - Must be manually deleted via Graph API or Entra portal
Code Reference
CleanupCommand.cs CreateBlueprintCleanupCommand handler deletes:
- Federated credentials
- Blueprint application (via
agentBlueprintService.DeleteAgentBlueprintAsync) - Messaging endpoint
But does not query for or delete:
- Agent identity SP (would need
GET /beta/servicePrincipalsfiltered by blueprint parent) - Agentic user (linked via
identityParentIdto the identity SP)
Impact
Users who run cleanup blueprint are left with orphaned Entra ID resources they cannot easily discover or remove. This is especially problematic in demo tenants where multiple blueprint create/delete cycles occur.
Suggested Fix
Before deleting the blueprint, query for instances:
GET /beta/servicePrincipals/microsoft.graph.agentIdentity
Filter results where the parent matches the blueprint being deleted. For each instance, delete the agentic user first (via DELETE /beta/agentUsers/{id} or az ad user delete), then the identity SP.