Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public static Command CreateCommand(
" 2. a365 setup blueprint\n" +
" 3. a365 setup permissions mcp\n" +
" 4. a365 setup permissions bot\n" +
" 5. a365 setup endpoint\n\n" +
"Or run all steps at once:\n" +
" a365 setup all # Full setup (includes infrastructure)\n" +
" a365 setup all --skip-infrastructure # Skip infrastructure if it already exists");
Expand All @@ -42,14 +41,11 @@ public static Command CreateCommand(
logger, configService, azureValidator, webAppCreator, platformDetector, executor));

command.AddCommand(BlueprintSubcommand.CreateCommand(
logger, configService, executor, azureValidator, webAppCreator, platformDetector));
logger, configService, executor, azureValidator, webAppCreator, platformDetector, botConfigurator));

command.AddCommand(PermissionsSubcommand.CreateCommand(
logger, configService, executor, graphApiService));

command.AddCommand(EndpointSubcommand.CreateCommand(
logger, configService, botConfigurator, platformDetector));

command.AddCommand(AllSubcommand.CreateCommand(
logger, configService, executor, botConfigurator, azureValidator, webAppCreator, platformDetector, graphApiService));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,14 @@ public static Command CreateCommand(
azureValidator,
logger,
skipInfrastructure,
true);
true,
configService,
botConfigurator,
platformDetector
);

setupResults.BlueprintCreated = blueprintCreated;
setupResults.MessagingEndpointRegistered = blueprintCreated;

if (blueprintCreated)
{
Expand All @@ -178,13 +183,14 @@ public static Command CreateCommand(
{
throw new SetupValidationException(
"Blueprint creation completed but AgentBlueprintId was not saved to configuration. " +
"This is required for the next steps (MCP permissions, Bot permissions, and endpoint registration).");
"This is required for the next steps (MCP permissions and Bot permissions).");
}
}
}
catch (Exception blueprintEx)
{
setupResults.BlueprintCreated = false;
setupResults.MessagingEndpointRegistered = false;
setupResults.Errors.Add($"Blueprint: {blueprintEx.Message}");
logger.LogError(blueprintEx, "Failed to create blueprint: {Message}", blueprintEx.Message);
throw;
Expand Down Expand Up @@ -245,30 +251,6 @@ public static Command CreateCommand(
logger.LogWarning("Setup will continue, but Bot API permissions must be configured manually");
}

// Step 5: Register endpoint and sync
logger.LogInformation("");
logger.LogInformation("Step 5:");
logger.LogInformation("");

try
{
await EndpointSubcommand.RegisterEndpointAndSyncAsync(
config.FullName,
logger,
configService,
botConfigurator,
platformDetector);

setupResults.MessagingEndpointRegistered = true;
logger.LogInformation("Blueprint messaging endpoint registered successfully");
}
catch (Exception endpointEx)
{
setupResults.MessagingEndpointRegistered = false;
setupResults.Errors.Add($"Messaging endpoint: {endpointEx.Message}");
logger.LogError("Failed to register messaging endpoint: {Message}", endpointEx.Message);
}

// Display verification info and summary
logger.LogInformation("");
await SetupHelpers.DisplayVerificationInfoAsync(config, logger);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Azure.Identity;
using Microsoft.Agents.A365.DevTools.Cli.Constants;
using Microsoft.Agents.A365.DevTools.Cli.Exceptions;
using Microsoft.Agents.A365.DevTools.Cli.Helpers;
using Microsoft.Agents.A365.DevTools.Cli.Services;
using Microsoft.Agents.A365.DevTools.Cli.Services.Helpers;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -34,7 +35,8 @@ public static Command CreateCommand(
CommandExecutor executor,
IAzureValidator azureValidator,
AzureWebAppCreator webAppCreator,
PlatformDetector platformDetector)
PlatformDetector platformDetector,
IBotConfigurator botConfigurator)
{
var command = new Command("blueprint",
"Create agent blueprint (Entra ID application registration)\n" +
Expand Down Expand Up @@ -78,7 +80,11 @@ await CreateBlueprintImplementationAsync(
azureValidator,
logger,
false,
false);
false,
configService,
botConfigurator,
platformDetector
);

}, configOption, verboseOption, dryRunOption);

Expand All @@ -93,6 +99,9 @@ public static async Task<bool> CreateBlueprintImplementationAsync(
ILogger logger,
bool skipInfrastructure,
bool isSetupAll,
IConfigService configService,
IBotConfigurator botConfigurator,
PlatformDetector platformDetector,
CancellationToken cancellationToken = default)
{
logger.LogInformation("");
Expand Down Expand Up @@ -247,17 +256,26 @@ await CreateBlueprintClientSecretAsync(
setupConfig,
logger);

// Final summary
logger.LogInformation("");
logger.LogInformation("Agent blueprint created successfully");
logger.LogInformation("Generated config saved: {Path}", generatedConfigPath);
logger.LogInformation("");

await RegisterEndpointAndSyncAsync(
configPath: config.FullName,
logger: logger,
configService: configService,
botConfigurator: botConfigurator,
platformDetector: platformDetector);

// Display verification info and summary
await SetupHelpers.DisplayVerificationInfoAsync(config, logger);

if (!isSetupAll)
{
logger.LogInformation("Next steps:");
logger.LogInformation(" 1. Run 'a365 setup permissions mcp' to configure MCP permissions");
logger.LogInformation(" 2. Run 'a365 setup permissions bot' to configure Bot API permissions");
logger.LogInformation(" 3. Run 'a365 setup endpoint' to register messaging endpoint");
}

return true;
Expand Down Expand Up @@ -828,6 +846,73 @@ await File.WriteAllTextAsync(
}
}

/// <summary>
/// Registers blueprint messaging endpoint and syncs project settings.
/// Public method that can be called by AllSubcommand.
/// </summary>
public static async Task RegisterEndpointAndSyncAsync(
string configPath,
ILogger logger,
IConfigService configService,
IBotConfigurator botConfigurator,
PlatformDetector platformDetector,
CancellationToken cancellationToken = default)
{
var setupConfig = await configService.LoadAsync(configPath);

if (string.IsNullOrWhiteSpace(setupConfig.AgentBlueprintId))
{
logger.LogError("Blueprint ID not found. Please confirm agent blueprint id is in config file.");
Environment.Exit(1);
}

if (string.IsNullOrWhiteSpace(setupConfig.WebAppName))
{
logger.LogError("Web App Name not found. Run 'a365 setup infrastructure' first.");
Environment.Exit(1);
}

logger.LogInformation("Registering blueprint messaging endpoint...");
logger.LogInformation("");

await SetupHelpers.RegisterBlueprintMessagingEndpointAsync(
setupConfig, logger, botConfigurator);


setupConfig.Completed = true;
setupConfig.CompletedAt = DateTime.UtcNow;

await configService.SaveStateAsync(setupConfig);

logger.LogInformation("");
logger.LogInformation("Blueprint messaging endpoint registered successfully");

// Sync generated config to project settings (appsettings.json or .env)
logger.LogInformation("");
logger.LogInformation("Syncing configuration to project settings...");

var configFileInfo = new FileInfo(configPath);
var generatedConfigPath = Path.Combine(
configFileInfo.DirectoryName ?? Environment.CurrentDirectory,
"a365.generated.config.json");

try
{
await ProjectSettingsSyncHelper.ExecuteAsync(
a365ConfigPath: configPath,
a365GeneratedPath: generatedConfigPath,
configService: configService,
platformDetector: platformDetector,
logger: logger);

logger.LogInformation("Configuration synced to project settings successfully");
}
catch (Exception syncEx)
{
logger.LogWarning(syncEx, "Project settings sync failed (non-blocking). Please sync settings manually if needed.");
}
}

#region Private Helper Methods

private static async Task<bool> CreateFederatedIdentityCredentialAsync(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,6 @@ public static void DisplaySetupSummary(SetupResults results, ILogger logger)
{
logger.LogInformation(" - Bot API Permissions: Run 'a365 setup permissions bot' to retry");
}

if (!results.MessagingEndpointRegistered)
{
logger.LogInformation(" - Messaging Endpoint: Run 'a365 setup endpoint' to retry");
}
}
else if (results.HasWarnings)
{
Expand Down
Loading
Loading