Skip to content

Commit dc5cb36

Browse files
committed
Simplify agent identity creation to always use delegated flow
Removed logic for app-only flow with client credentials in agent identity creation. Now always uses delegated flow, requiring only Agent ID Developer or Administrator role. Updated comments and warnings to reflect this change.
1 parent a3b34bb commit dc5cb36

1 file changed

Lines changed: 9 additions & 28 deletions

File tree

src/Microsoft.Agents.A365.DevTools.Cli/Commands/SetupSubcommands/NonDwBlueprintSetupOrchestrator.cs

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -278,33 +278,14 @@ public static async Task<int> ExecuteAsync(SetupContext ctx)
278278
?? ctx.Config.WebAppName
279279
?? "Agent";
280280

281-
// Agent identity creation: prefer app-only flow (blueprint client credentials) when available.
282-
// Fall back to delegated flow (AgentIdentity.Create.All) when the client secret is missing.
281+
// Agent identity creation via delegated flow (AgentIdentity.Create.All).
282+
// Agent ID Developer role is sufficient — client credentials are not required.
283283
ctx.Logger.LogInformation("Creating agent identity...");
284-
string? agentId = null;
285-
if (string.IsNullOrWhiteSpace(ctx.Config.AgentBlueprintClientSecret))
286-
{
287-
ctx.Logger.LogInformation("Blueprint client secret not available — attempting delegated flow...");
288-
agentId = await ctx.GraphApiService.CreateAgentIdentityDelegatedAsync(
289-
ctx.Config.TenantId!,
290-
ctx.Config.AgentBlueprintId!,
291-
agentIdentityDisplayName,
292-
ctx.CancellationToken);
293-
}
294-
else
295-
{
296-
var clientSecret = SecretProtectionHelper.UnprotectSecret(
297-
ctx.Config.AgentBlueprintClientSecret,
298-
ctx.Config.AgentBlueprintClientSecretProtected,
299-
ctx.Logger);
300-
301-
agentId = await ctx.GraphApiService.CreateAgentIdentityAsync(
302-
ctx.Config.TenantId!,
303-
ctx.Config.AgentBlueprintId!,
304-
clientSecret,
305-
agentIdentityDisplayName,
306-
ctx.CancellationToken);
307-
}
284+
var agentId = await ctx.GraphApiService.CreateAgentIdentityDelegatedAsync(
285+
ctx.Config.TenantId!,
286+
ctx.Config.AgentBlueprintId!,
287+
agentIdentityDisplayName,
288+
ctx.CancellationToken);
308289

309290
if (agentId is not null)
310291
{
@@ -320,8 +301,8 @@ public static async Task<int> ExecuteAsync(SetupContext ctx)
320301
else if (!ctx.Results.AgentIdentityFailed)
321302
{
322303
ctx.Results.AgentIdentityFailed = true;
323-
ctx.Results.Warnings.Add("Agent identity creation failed. Check the blueprint client secret and ensure the blueprint was set up correctly.");
324-
ctx.Logger.LogWarning("Agent identity creation failed. Check the blueprint client secret and ensure the blueprint was set up correctly.");
304+
ctx.Results.Warnings.Add("Agent identity creation failed. Ensure you have the Agent ID Developer or Agent ID Administrator role in this tenant.");
305+
ctx.Logger.LogWarning("Agent identity creation failed. Ensure you have the Agent ID Developer or Agent ID Administrator role in this tenant.");
325306
}
326307
}
327308

0 commit comments

Comments
 (0)