-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Description
a365 cleanup instance reads AgenticAppId and AgenticUserId from a365.generated.config.json to find the identity SP and agentic user to delete. However, these fields are never populated by any a365 command (setup, publish, deploy). They are always empty/null, so cleanup instance silently does nothing.
Steps to Reproduce
a365 setup all --skip-infrastructure --verbosea365 publish --verbose- Admin activates blueprint, user creates instance
- Examine
a365.generated.config.json—AgenticAppIdandAgenticUserIdare not present - Run
a365 cleanup instance— says "Starting instance cleanup..." then immediately completes without deleting anything
Expected Behavior
One of:
- Option A (Recommended): Deprecate this command. Since
create-instancewas already deprecated ("bypassed required registration steps"), and instances are now created through M365 Admin Center + Teams, the CLI never has the opportunity to write instance IDs to local config.cleanup instanceshould be deprecated and instance cleanup folded intocleanup blueprint(with cascade deletion or warnings). - Option B: Discover instances dynamically using the blueprint ID. The
AgentBlueprintIdis already populated ina365.generated.config.json. Use it to query for child instances via Graph API — e.g.,GET /beta/servicePrincipals/microsoft.graph.agentIdentityfiltered by the blueprint's parent app, then resolve agentic users viaidentityParentId. This would make the command functional without requiring any new config fields. - Option C:
a365 publishor some other command should populateAgenticAppIdandAgenticUserIdin the generated config after instance creation is detected.
Actual Behavior
cleanup instance guards every deletion behind if (!string.IsNullOrWhiteSpace(config.AgenticAppId)) and if (!string.IsNullOrWhiteSpace(config.AgenticUserId)). Since these are never populated, all deletion blocks are skipped. The command completes "successfully" without cleaning up anything.
Code Reference
CleanupCommand.cs lines ~355-366:
// Delete agent identity application
if (!string.IsNullOrWhiteSpace(config.AgenticAppId)) // Always empty -> skipped
{
logger.LogInformation("Deleting agent identity application...");
await executor.ExecuteAsync("az", $"ad app delete --id {config.AgenticAppId}", ...);
}
// Delete agent user
if (!string.IsNullOrWhiteSpace(config.AgenticUserId)) // Always empty -> skipped
{
logger.LogInformation("Deleting agent user...");
await executor.ExecuteAsync("az", $"ad user delete --id {config.AgenticUserId}", ...);
}Impact
Users believe they have cleaned up their instances but orphaned resources remain in Entra ID. Combined with the cleanup blueprint issue (which also doesn't clean up instances), there is no CLI path to properly clean up agent instances.
Additional Context
The create-instance command was deprecated per official docs: "bypassed required registration steps." Instance creation now happens exclusively through M365 Admin Center + Teams. Since the CLI no longer manages the instance lifecycle (create -> cleanup), this command is effectively dead code. Deprecating it and moving instance cleanup responsibility into cleanup blueprint (or a new cleanup all enhancement) would align the CLI with the current platform design.